/** * tx_dam::index_autoProcess() */ public function test_index_autoProcess() { $this->activateIndexSetup('set_keyword'); $this->removeFixturesFromIndex(); $this->addFixturePathToFilemount(); $filepath = $this->getFixtureFilename('iptc'); $uid = tx_dam::file_isIndexed($filepath); self::assertFalse($uid, 'File index found, but shouldn\'t'); tx_dam::config_setValue('setup.indexing.auto', false); $indexed = tx_dam::index_autoProcess($filepath, $reindex = false); self::assertFalse(isset($indexed['isIndexed']), 'File IS indexed but shouldn\'t'); tx_dam::config_setValue('setup.indexing.auto', true); $indexed = tx_dam::index_autoProcess($filepath, $reindex = false); self::assertTrue(isset($indexed['isIndexed']), 'File not indexed'); $meta = tx_dam::meta_getDataByUid($indexed['fields']['uid'], '*'); // keyword is set in auto indexing setup: dam/tests/fixtures/.indexing.setup.xml self::assertEquals($meta['keywords'], 'TEST', 'Wrong keyword: ' . $meta['keywords']); $date = date('d.m.Y', $meta['date_cr']); self::assertEquals($date, '04.07.2006', 'Wrong date: ' . $date); self::assertEquals($meta['title'], 'Hummelflug', 'Wrong title: ' . $meta['title']); self::assertEquals($meta['file_hash'], '184e454250f6f606a1dba14b5c7b38c5', 'Wrong file_hash: ' . $meta['file_hash']); self::assertEquals(intval($meta['media_type']), TXDAM_mtype_image, 'Wrong media_type: ' . $meta['media_type']); self::assertEquals($meta['file_type'], 'jpg', 'Wrong file_type: ' . $meta['file_type']); self::assertEquals($meta['file_mime_type'], 'image', 'Wrong file_mime_type: ' . $meta['file_mime_type']); self::assertEquals($meta['file_mime_subtype'], 'jpeg', 'Wrong file_mime_subtype: ' . $meta['file_mime_subtype']); self::assertTrue((bool) $meta['hpixels'], 'Missing value'); self::assertTrue((bool) $meta['vpixels'], 'Missing value'); self::assertTrue((bool) $meta['hres'], 'Missing value'); self::assertTrue((bool) $meta['vres'], 'Missing value'); self::assertTrue((bool) $meta['width'], 'Missing value'); self::assertTrue((bool) $meta['height'], 'Missing value'); self::assertTrue((bool) $meta['height_unit'], 'Missing value'); $this->removeFixturePathFromFilemount(); $this->removeFixturesFromIndex(); $this->removeIndexSetup(); }
/** * Notifies the DAM about (external) changes to names and movements about files or folders. * This will update all related meta data * * @param string $src File/folder name with path of the source that was changed. * @param string $dest File/folder name with path of the destination which is a new name or/and a new location. * @return void */ function notify_fileCopied($src, $dest) { if (@is_file($dest)) { if ($meta = tx_dam::meta_getDataForFile($src, '*', true)) { $fileInfo = tx_dam::file_compileInfo($dest); $values = $meta; $values['uid'] = 'NEW'; $values['deleted'] = '0'; $values['file_name'] = $fileInfo['file_name']; $values['file_path'] = $fileInfo['file_path']; $values['file_mtime'] = $fileInfo['file_mtime']; if ($meta['file_dl_name'] == $meta['file_name']) { $values['file_dl_name'] = $fileInfo['file_name']; } tx_dam_db::insertUpdateData($values); } else { // file is not yet indexed tx_dam::index_autoProcess($dest); } // the item is a folder } elseif (@is_dir($dest)) { tx_dam_db::cloneFilePath($src, $dest); } // else unknown }
/** * */ function autoIndex() { if ($meta = tx_dam::index_autoProcess($this->getPathAbsolute())) { $this->setMetaData($meta); } }
/** * Processes auto indexing if the file is not yet indexed * * @param array $item */ function autoIndex(&$item) { static $indexed = 0; if ($this->maxAutoIndexingItems and $indexed >= $this->maxAutoIndexingItems) { return; } // we don't index indexing setup files if ($item['file_name'] === '.indexing.setup.xml') { } elseif (!($uid = tx_dam::file_isIndexed($item))) { if ($metaRow = tx_dam::index_autoProcess($item)) { $item = $metaRow['fields']; $item['__isIndexed'] = true; $indexed++; } } }
/** * tx_dam::process_renameFile() */ public function test_process_renameFile() { $this->removeFixtureTempFiles(); $this->removeIndexSetup(); $this->removeFixturesFromIndex(); $this->addFixturePathToFilemount(); $filepath = $this->getFixtureTempFilename(); $uid = tx_dam::file_isIndexed($filepath); self::assertNoUID($uid, 'File index found, but shouldn\'t'); tx_dam::config_setValue('setup.indexing.auto', true); $indexed = tx_dam::index_autoProcess($filepath, $reindex = false); self::assertTrue(isset($indexed['isIndexed']), 'File not indexed'); $uid = $indexed['fields']['uid']; $filepathNew = $filepath . '.doc'; $error = tx_dam::process_renameFile($filepath, tx_dam::file_basename($filepathNew)); if ($error) { debug($error); } self::assertTrue(is_file($filepathNew), 'File not renamed'); $uid2 = tx_dam::file_isIndexed($filepathNew); self::assertUID($uid2, 'File index not found'); self::assertEquals(intval($uid), intval($uid2), 'Wrong uid: ' . $uid . ' - ' . $uid2); $data = tx_dam::meta_getDataByUid($uid); self::assertEquals($data['file_name'], tx_dam::file_basename($filepathNew), 'Wrong file name ' . $indexed['fields']['file_name'] . ' != ' . tx_dam::file_basename($filepathNew)); $this->removeFixturePathFromFilemount(); $this->removeFixturesFromIndex(); $this->removeIndexSetup(); $this->removeFixtureTempFiles(); }