| 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) { |
| 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 |
} |
} |
| 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 |