/[drupal]/contributions/modules/fast_gallery/storageengine/default.storage.inc
ViewVC logotype

Diff of /contributions/modules/fast_gallery/storageengine/default.storage.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5, Mon Nov 9 07:29:05 2009 UTC revision 1.6, Tue Nov 10 18:20:18 2009 UTC
# Line 52  class DefaultStorage implements Istorage Line 52  class DefaultStorage implements Istorage
52    public function storeImages($arImages) {    public function storeImages($arImages) {
53      global $user;      global $user;
54      static $first_run = TRUE;      static $first_run = TRUE;
55        static $runid;
56        $runid = variable_get('fast_gallery_runid', 0);
57    
58      //TODO: This makes the APP slow -> Rebuilding the whole      //TODO: This makes the APP slow -> Rebuilding the whole
59      // Gallery every time!      // Gallery every time!
60      if ($first_run) {      if ($first_run) {
61        db_query("TRUNCATE TABLE  `fast_gallery_hierarchy`");        db_query("TRUNCATE TABLE  `fast_gallery_hierarchy`");
62        db_query("TRUNCATE TABLE  `fast_gallery`");        //db_query("TRUNCATE TABLE  `fast_gallery`");
63        $first_run = FALSE;        $first_run = FALSE;
64          dsm($runid, "runid");
65          variable_set('fast_gallery_runid', ++$runid);
66      }      }
67    
68      foreach ($arImages as $image) {      foreach ($arImages as $image) {
# Line 69  class DefaultStorage implements Istorage Line 73  class DefaultStorage implements Istorage
73        $file->fid = $image->getFid();        $file->fid = $image->getFid();
74        file_save($file);        file_save($file);
75        $file->foid = $this->storeHierarchy($image);        $file->foid = $this->storeHierarchy($image);
76          $file->runid = $runid;
77    
       /*$args = array(':fid' => $file->fid, ':foid' => $file->foid);  
       $count = db_query("SELECT COUNT(fid) as count FROM {fast_gallery}  
                           WHERE fid=:fid AND foid=:foid", $args)->fetchField();  
       if ($count == 0) {  
   
       }*/  
   
       //TODO: Files sollten nur einmal drin stehen!!!! Es kann nämlich vorkommen  
       //dass die ordner von zwei galerien sich überschneiden  
78    
79          //only write file if it doesn't exist yet
80        $exists = db_query("SELECT count(fid) as c FROM {fast_gallery} WHERE fid=:fid AND foid=:foid", array(':fid' => $file->fid, ':foid' => $file->foid))->fetchField();        $exists = db_query("SELECT count(fid) as c FROM {fast_gallery} WHERE fid=:fid AND foid=:foid", array(':fid' => $file->fid, ':foid' => $file->foid))->fetchField();
   
81        if ($exists == 0) {        if ($exists == 0) {
82          drupal_write_record('fast_gallery', $file);          drupal_write_record('fast_gallery', $file);
83        }        }
84          else {
85            db_update('fast_gallery')
86            ->fields(array('runid' => $runid))
87            ->condition('fid', $file->fid)
88            ->execute();
89          }
90    
91      }      }
92    }    }
# Line 103  class DefaultStorage implements Istorage Line 105  class DefaultStorage implements Istorage
105    }    }
106    
107    /**    /**
108       * (non-PHPdoc)
109       * @see sites/all/modules/fast_gallery/storageengine/Istorage#removeDeletedFiles()
110       */
111      public function removeDeletedFiles() {
112    
113      }
114    
115      /**
116     * In order to retrieve the hierarchy we need to store this information     * In order to retrieve the hierarchy we need to store this information
117     * in a special table     * in a special table
118     * @param FGImage $image     * @param FGImage $image

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.2