/**
  * Downloads a bookmark favicon.
  *
  * @param string $url The bookmark URL.
  * @param int $id The feed id.
  */
 public function downloadBookmark(Bookmark $bookmark)
 {
     $icon = new Icon();
     $icon->id_bookmark = $bookmark->id;
     $icon->data = $this->downloadIcon($this->guessIconURL($bookmark->url));
     $icon->save();
 }
Beispiel #2
0
 /**
  * GET /icon/bookmark/:id
  *
  * @param int $id
  */
 public function oneBookmark($id)
 {
     $icon = new Icon();
     if ($icon->readOneBookmark($id)) {
         $this->icon($icon);
     } else {
         $this->app->render(404);
     }
 }
Beispiel #3
0
 /**
  * Imports the favicons into the database and deletes them from filesystem.
  */
 protected function importIcons()
 {
     $this->printLine('Importing icons…');
     $iconsDir = sprintf('%s/public/icons', getcwd());
     foreach ($this->types as $type) {
         $path = "{$iconsDir}/{$type}/*.ico";
         foreach (glob($path) as $file) {
             $icon = new Icon();
             $icon->data = file_get_contents($file);
             if ($type === 'feed') {
                 $icon->id_feed = str_replace('.ico', '', basename($file));
             } else {
                 $icon->id_bookmark = str_replace('.ico', '', basename($file));
             }
             if ($icon->save()) {
                 unlink($file);
             }
         }
     }
     $this->printLine('Icons imported!');
 }