Example #1
0
 public function create($albumPath, $square = false)
 {
     $albumView = new View($this->view->getRoot() . $albumPath);
     $images = $albumView->searchByMime('image', 10);
     $count = min(count($images), 10);
     $thumbnail = imagecreatetruecolor($count * 200, 200);
     for ($i = 0; $i < $count; $i++) {
         $thumb = new Thumbnail($albumPath . $images[$i]['path'], $this->user, true);
         $image = $thumb->get();
         if ($image && $image->valid()) {
             imagecopy($thumbnail, $image->resource(), $i * 200, 0, 0, 0, 200, 200);
             $image->destroy();
         }
     }
     imagepng($thumbnail, $this->path);
     imagedestroy($thumbnail);
 }
Example #2
0
 public function refresh()
 {
     $view = new \OC\Files\View('');
     //! need root ?
     $gpx_files = $view->searchByMime('application/gpx');
     $fileids = array();
     foreach ($gpx_files as $fileinfo) {
         $fileid = $fileinfo->getId();
         $fileids[$fileid] = false;
     }
     $sql = "select distinct fileid" . " from *PREFIX*gpx_tracks" . " WHERE user_id = ?";
     $prep = $this->db->prepare($sql);
     $prep->bindValue(1, $this->userId);
     $prep->execute($sql);
     $filesondb = $prep->fetchAll(\PDO::FETCH_ASSOC);
     //return $filesondb;
     $lost = array();
     foreach ($filesondb as $t) {
         $id = $t['fileid'];
         if (isset($fileids[$id])) {
             $fileids[$id] = true;
         } else {
             $lost[] = $id;
             //on the db but not in filecache
         }
     }
     $done = array();
     foreach ($fileids as $fileid => $status) {
         if (!$status) {
             $this->putAllTracks($fileid);
             $done[] = $fileid;
         }
     }
     return $done;
     //! TODO remove lost files records
 }
Example #3
0
 /**
  * @param string $query
  */
 public static function searchByMime($query)
 {
     return self::$defaultInstance->searchByMime($query);
 }