/** * */ protected function addFixturePathToFilemount() { $filepath = $this->getFixtureFilename(); $filename = tx_dam::file_basename($filepath); $testpath = tx_dam::file_dirname($filepath); $this->tempSave['fileadminDir'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] = tx_dam::path_makeRelative($testpath); $GLOBALS['FILEMOUNTS']['__unittest'] = array('name' => basename($testpath) . '/', 'path' => $testpath, 'type' => ''); }
/** * tx_dam::access_checkPath() */ public function test_access_checkPath() { $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array(); $filepath = $this->getFixtureFilename(); $testpath = tx_dam::file_dirname($filepath); // path is cached so we need to use a different: 01/ $access = tx_dam::access_checkPath($testpath . '01/'); self::assertFalse($access, 'Path is accessable: ' . $testpath . '01/'); $access = tx_dam::access_checkPath(PATH_site . 'fileadmin/'); self::assertTrue($access, 'Path not accessable: ' . PATH_site . 'fileadmin/'); $access = tx_dam::access_checkPath(PATH_site . 'fileadmin/zfhucnzushbfxcazu/'); self::assertFalse($access, 'Path is accessable: ' . PATH_site . 'fileadmin/zfhucnzushbfxcazu/'); $this->addFixturePathToFilemount(); $access = tx_dam::access_checkPath($testpath); self::assertTrue($access, 'Path not accessable: ' . $testpath); $this->removeFixturePathFromFilemount(); }
/** * Process indexing for the given file, folder or a list of files and folders. * This function can be used if a setup for indexing is available of callback function shall be used. * But simply a file name can be passed to and everything goes automatically. * * @param mixed $filename A single filename or folder path or a list of files and paths as array. If it is an array the values can be file path or array: array('processFile' => 'path to file that should be indexed', 'metaFile' => 'additional file that holds meta data for the processFile') * @param mixed $setup Setup as string (serialized setup) or array. See tx_dam_indexing::restoreSerializedSetup() * @param mixed $callbackFunc Callback function for the finished indexed file. * @param mixed $metaCallbackFunc Callback function which will be called during indexing to allow modifications to the meta data. * @param mixed $filePreprocessingCallbackFunc Callback function for pre processing the to be indexed file. * @return array Info array about indexed files and meta data records. * @todo how to set run type??? */ function index_process($filename, $setup = NULL, $callbackFunc = NULL, $metaCallbackFunc = NULL, $filePreprocessingCallbackFunc = NULL) { global $TYPO3_CONF_VARS; require_once PATH_txdam . 'lib/class.tx_dam_indexing.php'; $index = t3lib_div::makeInstance('tx_dam_indexing'); $index->init(); $index->setRunType('man'); $index->setDefaultSetup(); if ($setup) { $index->restoreSerializedSetup($setup); } elseif (!is_array($filename)) { $index->setDefaultSetup(tx_dam::file_dirname($filename)); } elseif ($filename['processFile']) { $index->setDefaultSetup(tx_dam::file_dirname($filename['processFile'])); } $index->setPID(); $index->initEnabledRules(); $index->setOptionsFromRules(); if ($filename['processFile']) { $index->setPathsList(array($filename)); } elseif (is_array($filename)) { $index->setPathsList($filename); } else { $index->setPath($filename); } return $index->indexUsingCurrentSetup($callbackFunc, $metaCallbackFunc, $filePreprocessingCallbackFunc); }
/** * tx_dam::path_compileInfo() */ public function test_path_compileInfo() { $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array(); $filepath = $this->getFixtureFilename(); $filename = tx_dam::file_basename($filepath); $testpath = tx_dam::file_dirname($filepath); $pathInfo = tx_dam::path_compileInfo($testpath); self::assertTrue(is_array($pathInfo), 'Path not found: ' . $testpath); self::assertTrue((bool) $pathInfo['dir_readable'], 'Path not readable: ' . $testpath); self::assertFALSE((bool) $pathInfo['mount_id'], 'Impossible mount found: ' . $pathInfo['mount_path'] . ' (' . $testpath . ')'); $pathInfo = tx_dam::path_compileInfo(PATH_site . 'fileadmin/'); self::assertTrue(is_array($pathInfo), 'Path not found: ' . $testpath); self::assertTrue((bool) $pathInfo['dir_readable'], 'Path not readable: ' . $testpath); self::assertTrue((bool) $pathInfo['mount_id'], 'No mount found: ' . $pathInfo['mount_path'] . ' (' . $testpath . ')'); }
/** * initialize the browsable trees * * @param array $TYPO3_CONF_VARS['EXTCONF']['dam']['selectionClasses'] * @param string script name to link to * @param boolean Element browser mode * @return void */ function initSelectionClasses($selectionClassesArr, $thisScript, $mode = 'browse', $excludeReadOnlyMounts = false) { global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS; $this->selectionClasses = $selectionClassesArr; // configuration - default $default_modeSelIcons = tx_dam::config_checkValueEnabled('setup.selections.default.modeSelIcons', true); if (is_array($this->selectionClasses)) { foreach ($this->selectionClasses as $classKey => $classRef) { // configuration - class if (!tx_dam::config_checkValueEnabled('setup.selections.' . $classKey, true)) { continue; } $config = tx_dam::config_getValue('setup.selections.' . $classKey, true); if (is_object($obj =& t3lib_div::getUserObj($classRef))) { if (!$obj->isPureSelectionClass) { if ($obj->isTreeViewClass) { // object is a treeview class itself $this->treeObjArr[$classKey] = $obj; $this->treeObjArr[$classKey]->init('', '', $excludeReadOnlyMounts); } else { // object does not include treeview functionality. Therefore the standard browsetree is used with setup from the object $this->treeObjArr[$classKey] =& t3lib_div::makeInstance('tx_dam_browseTree'); $this->treeObjArr[$classKey]->init(); $this->treeObjArr[$classKey]->title = $obj->getTreeTitle(); $this->treeObjArr[$classKey]->treeName = $obj->getTreeName(); $this->treeObjArr[$classKey]->domIdPrefix = $obj->domIdPrefix ? $obj->domIdPrefix : $obj->getTreeName(); $this->treeObjArr[$classKey]->rootIcon = PATH_txdam_rel . 'i/cat2folder.gif'; $this->treeObjArr[$classKey]->iconName = tx_dam::file_basename($obj->getDefaultIcon()); $this->treeObjArr[$classKey]->iconPath = tx_dam::file_dirname($obj->getDefaultIcon()); // workaround: Only variables can be passed by reference $this->treeObjArr[$classKey]->_data = $obj->getTreeArray(); $this->treeObjArr[$classKey]->setDataFromArray($this->treeObjArr[$classKey]->_data); } $this->treeObjArr[$classKey]->thisScript = $thisScript; $this->treeObjArr[$classKey]->BE_USER = $BE_USER; $this->treeObjArr[$classKey]->mode = $mode; $this->treeObjArr[$classKey]->ext_IconMode = '1'; // no context menu on icons if (!$default_modeSelIcons or !tx_dam::config_isEnabledOption($config, 'modeSelIcons', true)) { $this->treeObjArr[$classKey]->modeSelIcons = false; } } if ($this->treeObjArr[$classKey]->supportMounts) { $mounts = $this->getMountsForTreeClass($classKey, $this->treeObjArr[$classKey]->getTreeName()); if (count($mounts)) { $this->treeObjArr[$classKey]->setMounts($mounts); } else { unset($this->treeObjArr[$classKey]); } } } } } }