/**
  * Return dam record
  *
  * @param integer $uid uid of media element.
  * @param string $as name of element which is used for the dam record
  * @return string
  * @throws Tx_Fluid_Core_ViewHelper_Exception
  */
 public function render($uid, $as)
 {
     if (!t3lib_extMgm::isLoaded('dam')) {
         throw new Tx_Fluid_Core_ViewHelper_Exception('DamViewHelper needs a loaded DAM extension', 1318786684);
     }
     if ($GLOBALS['TSFE']->sys_language_content > 0) {
         $media = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_news_domain_model_media', 'deleted=0 AND uid =' . $uid);
         $media = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_news_domain_model_media', $media, $GLOBALS['TSFE']->sys_language_content);
         if ($media['_LOCALIZED_UID'] > 0) {
             // Does this localized media has dam record?
             $where = 'uid_foreign =' . (int) $media['_LOCALIZED_UID'] . ' AND tablenames =\'tx_news_domain_model_media\' AND ident = \'tx_news_media\'';
             $damRec = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid_local', 'tx_dam_mm_ref', $where);
             if (is_array($damRec) && $damRec['uid_local']) {
                 $uid = $media['_LOCALIZED_UID'];
             }
         }
     }
     $res = tx_dam_db::referencesQuery('tx_dam', '', 'tx_news_domain_model_media', (int) $uid, $mmIdent = '', $mmTable = 'tx_dam_mm_ref', $fields = 'tx_dam.*');
     $record = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     $this->templateVariableContainer->add($as, $record);
     $output = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $output;
 }
 /**
  * tx_dam_db::getPid()
  */
 public function test_getPID()
 {
     $pid = tx_dam_db::getPid();
     self::assertTrue($pid > 0, 'No DAM sysfolder detected/created');
     $pid = tx_dam_db::getPidList();
     self::assertTrue(!($pid == '0'), 'No DAM sysfolder detected/created');
 }
 /**
  * Entry function that hooks into the main typo3/alt_clickmenu.php,
  * see ext_tables.php of this extension for more info
  *
  * @param $backRef		the clickMenu object
  * @param $menuItems	the menuItems as an array that are already filled from the main clickmenu 
  * @param $table	the table that is worked on (tx_dam_cat only)
  * @param $uid		the item UID that is worked on
  * @return unknown
  */
 function main(&$backRef, $menuItems, $table, $uid)
 {
     if ($table != 'tx_dam_cat') {
         return $menuItems;
     }
     $this->backRef =& $backRef;
     // Get record
     $this->rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
     $menuItems = array();
     $root = !strcmp($uid, '0') ? true : false;
     if (is_array($this->rec) || $root) {
         $lCP = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $root ? tx_dam_db::getPid() : $this->rec['pid']));
         // Edit
         if (!$root && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'edit') && !in_array('edit', $this->backRef->disabledItems)) {
             $menuItems['edit'] = $this->DAMcatEdit($table, $uid);
         }
         // New Category
         if (!in_array('new', $this->backRef->disabledItems) && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'new')) {
             $menuItems['new'] = $this->DAMnewSubCat($table, $uid);
         }
         // Info
         if (!in_array('info', $this->backRef->disabledItems) && !$root) {
             $menuItems['info'] = $this->DAMcatInfo($table, $uid);
         }
         // Delete
         $elInfo = array(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getRecordTitle($table, $this->rec), $GLOBALS['BE_USER']->uc['titleLen']));
         if (!in_array('delete', $this->backRef->disabledItems) && !$root && $GLOBALS['BE_USER']->isPSet($lCP, $table, 'delete')) {
             $menuItems['spacer2'] = 'spacer';
             $menuItems['delete'] = $this->DAMcatDelete($table, $uid, $elInfo);
         }
     }
     return $menuItems;
 }
 /**
  * Main function
  *
  * @return	void
  */
 function main()
 {
     global $LANG, $TCA, $BACK_PATH;
     $content = '';
     $param = t3lib_div::_GP('edit');
     $table = key($param);
     $uid = (string) key($param[$table]);
     $cmd = $param[$table][$uid];
     if (is_array($TCA[$table]) and $cmd == 'new') {
         $this->defaultPid = tx_dam_db::getPid();
         $getArray['edit'][$table][$this->defaultPid] = 'new';
         $getArray['defVals'] = t3lib_div::_GP('defVals');
         $getArray['defVals'][$table]['pid'] = $this->defaultPid;
         $getArray['returnUrl'] = $this->pObj->returnUrl;
         $getArray['redirect'] = $this->pObj->redirect;
         $getArray = t3lib_div::compileSelectedGetVarsFromArray('returnUrl,redirect,edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId', $getArray);
         $getUrl = t3lib_div::implodeArrayForUrl('', $getArray);
         header('Location: ' . $BACK_PATH . 'alt_doc.php?id=' . $this->defaultPid . $getUrl);
         exit;
     } else {
         $content .= 'wrong comand!';
     }
     #TODO do it always this way (with if)
     if ($this->pObj->returnUrl) {
         $content .= '<br /><br />' . $this->pObj->btn_back('', $this->pObj->returnUrl);
     }
     // todo csh
     #		$content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH'],'<br/>');
     return $content;
 }
 public function postProcessDiffView($table, $fieldName, $recordOld, $recordNew, $currentDiff, $parentObject)
 {
     $diffView = $currentDiff;
     if ($table == 'tt_content' && $fieldName == 'tx_damttcontent_files' && $this->needsPostProcessing($recordOld, $recordNew)) {
         $filesOld = tx_dam_db::getReferencedFiles('tt_content', $recordOld['uid'], $this->fileFieldConfiguration['MM_match_fields'], $this->fileFieldConfiguration['MM'], 'tx_dam.*');
         $filesNew = tx_dam_db::getReferencedFiles('tt_content', $recordNew['uid'], $this->fileFieldConfiguration['MM_match_fields'], $this->fileFieldConfiguration['MM'], 'tx_dam.*');
         // building a string represemtation of the fields that can then
         // be sent to t3lib_diff, also collect the files to replace later
         $fieldContentOld = array();
         $placeholders = array();
         foreach ($filesOld['rows'] as $damFile) {
             $fieldContentOld[] = 'tx_dam:' . $damFile['uid'];
             $placeholders['tx_dam:' . $damFile['uid']] = $damFile;
         }
         $fieldContentOld = implode(' ', $fieldContentOld);
         $fieldContentNew = array();
         foreach ($filesNew['rows'] as $damFile) {
             $fieldContentNew[] = 'tx_dam:' . $damFile['uid'];
             $placeholders['tx_dam:' . $damFile['uid']] = $damFile;
         }
         $fieldContentNew = implode(' ', $fieldContentNew);
         // create the diff
         $diff = t3lib_div::makeInstance('t3lib_diff');
         $fieldDiff = $diff->makeDiffDisplay($fieldContentOld, $fieldContentNew, 'div');
         // replace placeholders with thumbnail and title
         foreach ($placeholders as $placeholder => $damFile) {
             $thumbnail = tx_dam_guiFunc::thumbnail($damFile);
             $replacement = $thumbnail . ' ' . $damFile['title'];
             $fieldDiff = str_replace($placeholder, $replacement, $fieldDiff);
         }
         $diffView = $fieldDiff;
     }
     return $diffView;
 }
 /**
  * Preprocesses the preview rendering of a content element.
  *
  * @param	tx_cms_layout		$parentObject: Calling parent object
  * @param	boolean				$drawItem: Whether to draw the item using the default functionalities
  * @param	string				$headerContent: Header content
  * @param	string				$itemContent: Item content
  * @param	array				$row: Record row of tt_content
  * @return	void
  */
 public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
 {
     if ($row['tx_damttcontent_files']) {
         $config =& $GLOBALS['TCA']['tt_content']['columns']['tx_damttcontent_files']['config'];
         $record = $this->determineRecord($row);
         $damItems = tx_dam_db::getReferencedFiles('tt_content', $record['uid'], $config['MM_match_fields'], $config['MM'], 'tx_dam.*');
         if ($damItems['rows']) {
             $itemContent = $this->renderDamItems($damItems['rows']);
         }
     }
 }
 /**
  * Track uploads/* files
  */
 function processDatamap_afterDatabaseOperations($status, $table, $id, &$fieldArray, $tce)
 {
     // files are moved ...
     if (is_array($tce->copiedFileMap) and count($tce->copiedFileMap)) {
         // Let's go
         foreach ($tce->copiedFileMap as $source => $dest) {
             // let's update the file tracking
             tx_dam_db::trackingUploadsFile($dest);
         }
     }
 }
Пример #8
0
 /**
  * Will return an array of Tx_ExtbaseDam_Domain_Model_Dam objects for the given table/uid/ident combination.
  *
  * @var string $table The table that dam-records have to be fetched for.
  * @var int $uid The UID of the record for which the dam-records have to be fetched for.
  * @var string $ident The field ident that dam-records have to be fetched for.
  * @var string $orderBy Any ordering that should be applied.
  * @var int $limit The maximum amount of objects to return.
  * @return array An array of Dam objects.
  */
 public static function get($table, $uid, $ident, $orderBy = '', $limit = 1000)
 {
     // check if this exact function call has been made before and give the cached result
     if (isset(self::$objectStorage['ref'][$table][$uid][$ident][$orderBy][$limit])) {
         return self::$objectStorage['ref'][$table][$uid][$ident][$orderBy][$limit];
     }
     // gets the data from DAM
     $damArray = tx_dam_db::getReferencedFiles($table, $uid, $ident, 'tx_dam_mm_ref', 'tx_dam.*', array(), '', $orderBy, $limit);
     $rows = $damArray['rows'];
     if (count($rows) > 0) {
         // dataMapper is a singleton
         $dataMapper = t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_DataMapper');
         $objects = $dataMapper->map('Tx_ExtbaseDam_Domain_Model_Dam', $rows);
         // cache the function call
         self::$objectStorage['ref'][$table][$uid][$ident][$orderBy][$limit] = $objects;
         return $objects;
     }
     self::$objectStorage['ref'][$table][$uid][$ident][$orderBy][$limit] = array();
     // no records found
     return array();
 }
    /**
     * List media types, along with options to edit & delete
     *
     * @return	string		HTML table of all the mimetypes
     */
    function listMimeTypes()
    {
        global $LANG, $BACK_PATH, $BE_USER;
        // Load template
        $content = t3lib_parsehtml::getSubpart(t3lib_div::getURL($BACK_PATH . t3lib_extMgm::extRelPath('dam') . 'modfunc_tools_mimetypes/template.html'), '###MOD_TEMPLATE###');
        $rowTemplate[1] = t3lib_parsehtml::getSubpart($content, '###ROW_1###');
        $rowTemplate[2] = t3lib_parsehtml::getSubpart($content, '###ROW_2###');
        // Add some JS
        $this->pObj->doc->JScode .= $this->pObj->doc->wrapScriptTags('
				function deleteRecord(id)	{	//
					if (confirm(' . $LANG->JScharCode($LANG->getLL('deleteWarning')) . '))	{
						window.location.href = "' . $BACK_PATH . 'tce_db.php?cmd[tx_dam_media_types]["+id+"][delete]=1&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&vC=' . $BE_USER->veriCode() . '&prErr=1&uPT=1";
					}
					return false;
				}
		');
        // Get content
        $alternate = 1;
        $rows = '';
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dam_media_types', '', '', 'ext ASC');
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            $editURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . ']=edit';
            //$deleteURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode( t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') ) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . '][delete]=1';
            $rowMarkers['EDIT'] = '<a href="#" onclick="window.location.href=\'' . $editURL . '\'; return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="Edit this type" alt="" height="16" width="16"></a>';
            $rowMarkers['DELETE'] = '<a href="#" onclick="deleteRecord(' . $row['uid'] . ')"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/deletedok.gif', 'width="11" height="12"') . ' title="Delete this type" alt="" height="16" width="16"></a>';
            $rowMarkers['EXTENSION'] = $row['ext'];
            $rowMarkers['MIME'] = $row['mime'];
            $rowMarkers['ICON'] = '<img src="' . $BACK_PATH . tx_dam::icon_getFileType(array('file_type' => $row['ext'], 'media_type' => $row['type'])) . '" />';
            $rows .= t3lib_parsehtml::substituteMarkerArray($rowTemplate[$alternate], $rowMarkers, '###|###');
            // Cycle the alternating rows
            if ($alternate == 2) {
                $alternate = 1;
            } else {
                $alternate = 2;
            }
        }
        $content = t3lib_parsehtml::substituteSubpart($content, '###ROWS###', $rows);
        $GLOBALS['TYPO3_DB']->sql_free_result($res);
        return $content;
    }
 /**
  * Init dam config values - which means they are fetched from TSConfig
  *
  * @param	boolean $force Will force the initialization to be done again except definedTSconfig set by config_setValue
  * @return void
  */
 function init($force = false)
 {
     $config =& $GLOBALS['T3_VAR']['ext']['dam']['config'];
     $perfomMerge = false;
     if (!is_array($config)) {
         $config = array();
         $config['mergedTSconfig.'] = array();
         $config['definedTSconfig.'] = array();
     }
     if (($force or !is_array($config['userTSconfig.'])) and $TSconfig = tx_dam_config::_getTSconfig()) {
         $config['pageUserTSconfig.'] = $config['userTSconfig.'] = $TSconfig;
         $perfomMerge = true;
     }
     if ($force or !is_array($config['pageTSconfig.'])) {
         if ($pid = tx_dam_db::getPid() and $TSconfig = tx_dam_config::_getTSconfig($pid)) {
             $config['pageTSconfig.'] = $TSconfig;
             $config['pageUserTSconfig.'] = t3lib_div::array_merge_recursive_overrule((array) $config['pageTSconfig.'], (array) $config['userTSconfig.']);
             $perfomMerge = true;
         }
     }
     if ($perfomMerge) {
         $config['mergedTSconfig.'] = t3lib_div::array_merge_recursive_overrule((array) $config['pageUserTSconfig.'], (array) $config['definedTSconfig.']);
     }
 }
Пример #11
0
 /**
  * The method get image-informations, included with extension DAM, from the Database
  * @author Caspar Stuebs
  *
  *	Returns:
  *	array (
  *		'files' => array(
  *			record-uid => 'fileadmin/example.jpg',
  *		)
  *		'rows' => array(
  *			record-uid => array(meta data array),
  *		)
  *	);
  *
  * @param	string	$table: The table where the image is included
  * @param	mixed	$uid: The uid from the table to look for the image. should be one uid, a comma-seperated list of uids, an array of uids or emtpy for all
  * @param	string	$ident: The fieldname from the table where the images are included, empty for all
  * @param	mixed	$where: Additional where clause as array or string (key => value)
  * @param	array	$fields: Additional fields from $table
  *
  * @return array	An array with image-informations, ordered by tx_dam_mm_ref.ident, tx_dam_mm_ref.sorting_foreign; false, if DAM is not loaded
  */
 function getDamImages($table = 'tt_content', $uid = '', $ident = '', $where = array(), $fields = array())
 {
     $return = false;
     $addFields = '';
     if (t3lib_extMgm::isLoaded('dam')) {
         if (is_array($uid)) {
             $uid = implode(',', $uid);
         }
         //if(!is_array($where)) $where = array();
         if (!is_array($fields) && !empty($fields) && $fields != 'uid') {
             $addFields = ',' . $table . '.' . $fields;
         } elseif (is_array($fields) && count($fields)) {
             foreach ($fields as $field) {
                 if ($field != 'uid') {
                     $addFields = ',' . $table . '.' . $field;
                 }
             }
         }
         $return = tx_dam_db::getReferencedFiles($table, $uid, $ident, 'tx_dam_mm_ref', 'tx_dam.*,tx_dam_mm_ref.*' . $addFields, $where, '', 'tx_dam_mm_ref.ident, tx_dam_mm_ref.sorting_foreign');
     }
     return $return;
 }
Пример #12
0
 function handleDam()
 {
     if ($this->useDam()) {
         $bSimulatedUser = FALSE;
         global $BE_USER;
         if (!isset($BE_USER) || !is_object($BE_USER) || intval($GLOBALS["BE_USER"]->user["uid"]) === 0) {
             // no be_user available
             // we are using the one created for formidable+dam, named _formidable+dam
             $rSql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery("uid", "be_users", "LOWER(username)='_formidable+dam'");
             if (($aRs = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($rSql)) !== FALSE) {
                 // we found user _formidable+dam
                 // simulating user
                 unset($BE_USER);
                 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth');
                 $BE_USER->OS = TYPO3_OS;
                 $BE_USER->setBeUserByUid($aRs["uid"]);
                 $BE_USER->fetchGroupData();
                 $BE_USER->backendSetUC();
                 $GLOBALS['BE_USER'] = $BE_USER;
                 $bSimulatedUser = TRUE;
             } else {
                 $this->oForm->mayday("renderlet:UPLOAD[name=" . $this->_getName() . "] /dam/use is enabled; for DAM to operate properly, you have to create a backend-user named '_formidable+dam' with permissions on dam tables");
             }
         }
         if ($this->isMultiple()) {
             $aFiles = t3lib_div::trimExplode(",", $this->getValue());
         } else {
             $aFiles = array($this->getValue());
         }
         reset($aFiles);
         while (list(, $sFileName) = each($aFiles)) {
             $sFilePath = $this->getServerPath($sFileName);
             tx_dam::notify_fileChanged($sFilePath);
             $oMedia = tx_dam::media_getForFile($sFilePath);
             if (($mTitle = $this->_navConf("/dam/addtitle")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mTitle)) {
                     $mTitle = $this->callRunneable($mTitle, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $oMedia->meta["title"] = $mTitle;
                 if (trim($mTitle) !== '') {
                     $oMedia->meta["title"] = $mTitle;
                 }
             }
             if (($mDescription = $this->_navConf("/dam/adddescription")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mDescription)) {
                     $mDescription = $this->callRunneable($mDescription, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $oMedia->meta["description"] = $mDescription;
                 if (trim($mDescription) !== '') {
                     $oMedia->meta["description"] = $mDescription;
                 }
             }
             if (($mCaption = $this->_navConf("/dam/addcaption")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mCaption)) {
                     $mCaption = $this->callRunneable($mCaption, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 if (trim($mCaption) !== '') {
                     $oMedia->meta["caption"] = $mCaption;
                 }
             }
             if (($mCategories = $this->_navConf("/dam/addcategories")) !== FALSE) {
                 require_once PATH_txdam . "lib/class.tx_dam_db.php";
                 $aCurCats = $GLOBALS["TYPO3_DB"]->exec_SELECTgetRows("uid_foreign", "tx_dam_mm_cat", "uid_local='" . $oMedia->meta["uid"] . "'", "", "sorting ASC");
                 if (!is_array($aCurCats)) {
                     $aCurCats = array();
                 }
                 reset($aCurCats);
                 while (list($sKey, ) = each($aCurCats)) {
                     $aCurCats[$sKey] = $aCurCats[$sKey]["uid_foreign"];
                 }
                 if (tx_ameosformidable::isRunneable($mCategories)) {
                     $mCategories = $this->callRunneable($mCategories, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $aCategories = array();
                 if (!is_array($mCategories)) {
                     if (trim($mCategories) !== "") {
                         $aCategories = t3lib_div::trimExplode(",", trim($mCategories));
                     }
                 } else {
                     $aCategories = $mCategories;
                 }
                 if (count($aCategories) > 0) {
                     reset($aCurCats);
                     $aCategories = array_unique(array_merge($aCurCats, $aCategories));
                     if (!empty($aCategories)) {
                         $oMedia->meta["category"] = implode(",", $aCategories);
                     }
                 }
             }
             tx_dam_db::insertUpdateData($oMedia->meta);
         }
         if ($bSimulatedUser === TRUE) {
             unset($BE_USER);
             unset($GLOBALS["BE_USER"]);
         }
     }
 }
 /**
  * Initializes the backend module by setting internal variables
  *
  * @return	void
  */
 function init()
 {
     global $TYPO3_CONF_VARS, $FILEMOUNTS;
     // name might be set from outside
     if (!$this->MCONF['name']) {
         $this->MCONF = $GLOBALS['MCONF'];
     }
     tx_dam::config_init();
     # tx_dam::config_setValue('setup.devel', '1');
     $this->defaultPid = tx_dam_db::getPid();
     $this->id = $this->defaultPid;
     // from parent::init();
     $this->CMD = t3lib_div::_GP('CMD');
     $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
     $this->menuConfig();
     $this->handleExternalFunctionValue();
     // include the default language file
     $GLOBALS['LANG']->includeLLFile('EXT:dam/lib/locallang.xml');
     //
     // Get current folder
     //
     // tx_dam_folder could be set by GP or stored in module conf
     $SET = t3lib_div::_GP('SET');
     $this->path = $this->MOD_SETTINGS['tx_dam_folder'];
     // check if tx_dam_folder was set by GP which takes precedence, if not use command sent by navframe
     // order: GP (script), SLCMD (navframe), MOD_SETTINGS (stored)
     $SLCMD = t3lib_div::_GPmerged('SLCMD');
     if (!$SET['tx_dam_folder'] and is_array($SLCMD['SELECT']) and is_array($SLCMD['SELECT']['txdamFolder'])) {
         $this->path = tx_dam::path_makeRelative(key($SLCMD['SELECT']['txdamFolder']));
     }
     $this->checkOrSetPath();
     $this->pageinfo = t3lib_BEfunc::readPageAccess($this->defaultPid, $this->perms_clause);
     $this->calcPerms = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
     //
     // Detect and set forced single function and set params
     //
     // remove selection command from any params
     $this->addParams['SLCMD'] = '';
     $this->addParams['SET'] = '';
     // forced a module function?
     $forcedFunction = t3lib_div::_GP('forcedFunction');
     if ($this->MOD_MENU['function'][$forcedFunction]) {
         $this->forcedFunction = $forcedFunction;
         $this->addParams['forcedFunction'] = $this->forcedFunction;
         $this->handleExternalFunctionValue('function', $this->forcedFunction);
     }
     //
     // Init selection
     //
     $this->selection = t3lib_div::makeInstance('tx_dam_selectionQuery');
     $maxPages = $this->config_checkValueEnabled('browserMaxPages', 20);
     $this->MOD_SETTINGS['tx_dam_resultPointer'] = $this->selection->initPointer($this->MOD_SETTINGS['tx_dam_resultPointer'], $this->MOD_SETTINGS['tx_dam_resultsPerPage'], $maxPages);
     $this->selection->initSelection($this, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['selectionClasses'], 'tx_dam', 'tx_dam_select');
     $this->selection->initQueryGen();
     $this->selection->qg->initBESelect('tx_dam', tx_dam_db::getPidList());
     $this->selection->addFilemountsToQuerygen();
     // debug output
     if (tx_dam::config_getValue('setup.devel')) {
         $this->debugContent['MOD_SETTINGS'] = '<h4>MOD_SETTINGS</h4>' . t3lib_div::view_array($this->MOD_SETTINGS);
     }
     // BE Info output
     if (tx_dam::config_getValue('setup.devel') and t3lib_extMgm::isLoaded('cc_beinfo')) {
         require_once t3lib_extMgm::extPath('cc_beinfo') . 'class.tx_ccbeinfo.php';
         $beinfo = t3lib_div::makeInstance('tx_ccbeinfo');
         $beinfoContent = $beinfo->makeInfo($this);
         $this->debugContent['beinfo'] = '<h4>BE Info</h4>' . $beinfoContent;
     }
 }
 /**
  * Main function
  *
  * @return	string		HTML output
  */
 function main()
 {
     global $BE_USER, $LANG, $BACK_PATH, $TCA, $TYPO3_CONF_VARS;
     $content = '';
     $table = 'tx_dam';
     //
     // get records by query depending on option 'Show deselected only'
     //
     $origSel = $this->pObj->selection->sl->sel;
     if ($this->pObj->MOD_SETTINGS['tx_dam_list_list_onlyDeselected']) {
         if (is_array($this->pObj->selection->sl->sel['NOT']['txdamRecords'])) {
             $excludeUidList = array_keys($this->pObj->selection->sl->sel['NOT']['txdamRecords']);
         } else {
             $excludeUidList = array(0);
             //dummy
         }
         unset($this->pObj->selection->sl->sel['NOT']['txdamRecords']);
         $this->pObj->selection->addSelectionToQuery();
         if (is_array($excludeUidList)) {
             $this->pObj->selection->qg->query['WHERE']['WHERE']['NOT_txdamRecords'] = 'AND tx_dam.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList(implode(',', $excludeUidList)) . ')';
         }
     } else {
         // will display deselected unset($this->pObj->selection->sl->sel['NOT']['txdamRecords']);
         $this->pObj->selection->addSelectionToQuery();
     }
     $this->pObj->selection->sl->sel = $origSel;
     //
     // set language query
     //
     $langRows = $this->pObj->getLanguages($this->pObj->defaultPid);
     $langCurrent = intval($this->pObj->MOD_SETTINGS['tx_dam_list_langSelector']);
     if (!isset($langRows[$langCurrent])) {
         $langCurrent = $this->pObj->MOD_SETTINGS['tx_dam_list_langSelector'] = key($langRows);
     }
     $langQuery = '';
     $languageField = $TCA[$table]['ctrl']['languageField'];
     if ($langCurrent && $this->pObj->MOD_SETTINGS['tx_dam_list_langOverlay'] === 'exclusive') {
         // if ($langCurrent) { This works but create NULL columns for non-translated records so we need to use language overlay anyway
         $lgOvlFields = tx_dam_db::getLanguageOverlayFields($table, 'tx_dam_lgovl');
         $languageField = $TCA[$table]['ctrl']['languageField'];
         $transOrigPointerField = $TCA[$table]['ctrl']['transOrigPointerField'];
         $this->pObj->selection->setSelectionLanguage($langCurrent);
         $this->pObj->selection->qg->query['SELECT']['tx_dam as tx_dam_lgovl'] = implode(', ', $lgOvlFields) . ', tx_dam.uid as _dlg_uid, tx_dam.title as _dlg_title';
         $this->pObj->selection->qg->query['LEFT_JOIN']['tx_dam as tx_dam_lgovl'] = 'tx_dam.uid=tx_dam_lgovl.' . $transOrigPointerField;
         if ($this->pObj->MOD_SETTINGS['tx_dam_list_langOverlay'] === 'exclusive') {
             $this->pObj->selection->qg->query['WHERE']['WHERE']['tx_dam_lgovl.' . $languageField] = 'AND tx_dam_lgovl.' . $languageField . '=' . $langCurrent;
             $this->pObj->selection->qg->query['WHERE']['WHERE']['tx_dam_lgovl.deleted'] = 'AND tx_dam_lgovl.deleted=0';
         } else {
             $this->pObj->selection->qg->query['WHERE']['WHERE']['tx_dam_lgovl.' . $languageField] = 'AND (tx_dam_lgovl.' . $languageField . ' IN (' . $langCurrent . ', 0, -1) )';
             $this->pObj->selection->qg->query['WHERE']['WHERE']['tx_dam_lgovl.deleted'] = 'AND (tx_dam_lgovl.sys_language_uid=1 OR tx_dam.sys_language_uid=0 )';
         }
     } else {
         $this->pObj->selection->qg->query['WHERE']['WHERE']['tx_dam.' . $languageField] = 'AND tx_dam.' . $languageField . ' IN (0,-1)';
     }
     //
     // Add the current selection to the query
     //
     #		$this->pObj->selection->addSelectionToQuery();
     //
     // Use the current selection to create a query and count selected records
     //
     $this->pObj->selection->execSelectionQuery(TRUE);
     //
     // output header: info bar, result browser, ....
     //
     $content .= $this->pObj->guiItems->getOutput('header');
     $content .= $this->pObj->doc->spacer(10);
     // any records found?
     if ($this->pObj->selection->pointer->countTotal) {
         //
         // init db list object
         //
         $dblist = t3lib_div::makeInstance('tx_dam_listrecords');
         $dblist->setParameterName('form', $this->pObj->formName);
         $dblist->init($table);
         $dblist->setActionsEnv(array('currentLanguage' => $langCurrent, 'allowedLanguages' => $langRows));
         //
         // process multi action if needed
         //
         if ($processAction = $dblist->getMultiActionCommand()) {
             if ($processAction['onItems'] === '_all') {
                 $uidList = array();
                 $res = $this->pObj->selection->execSelectionQuery();
                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                     $uidList[] = $row['uid'];
                 }
                 $itemList = implode(',', $uidList);
             } else {
                 $itemList = $processAction['onItems'];
                 $uidList = t3lib_div::trimExplode(',', $itemList, true);
             }
             if ($uidList) {
                 switch ($processAction['actionType']) {
                     case 'url':
                         $url = str_replace('###ITEMLIST###', $itemList, $processAction['action']);
                         header('Location: ' . $url);
                         exit;
                         break;
                     case 'tce-data':
                         $params = '';
                         foreach ($uidList as $uid) {
                             $params .= str_replace('###UID###', $uid, $processAction['action']);
                         }
                         $url = $GLOBALS['SOBE']->doc->issueCommand($params, -1);
                         $url = $BACK_PATH . 'tce_db.php?&redirect=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '&vC=' . $BE_USER->veriCode() . '&prErr=1&uPT=1' . $params;
                         header('Location: ' . $url);
                         exit;
                         break;
                 }
             }
         }
         t3lib_div::loadTCA($table);
         //
         // set fields to display
         //
         $titleColumn = $TCA[$table]['ctrl']['label'];
         $allFields = tx_dam_db::getFieldListForUser($table);
         $selectedFields = t3lib_div::_GP('tx_dam_list_list_displayFields');
         $selectedFields = is_array($selectedFields) ? $selectedFields : explode(',', $this->pObj->MOD_SETTINGS['tx_dam_list_list_displayFields']);
         // remove fields that can not be selected
         if (is_array($selectedFields)) {
             $selectedFields = array_intersect($allFields, $selectedFields);
             $selectedFields = array_merge(array($titleColumn), $selectedFields);
         } else {
             $selectedFields = array();
             $selectedFields[] = $titleColumn;
         }
         // store field list
         $this->pObj->MOD_SETTINGS['tx_dam_list_list_displayFields'] = implode(',', $selectedFields);
         $GLOBALS['BE_USER']->pushModuleData($this->pObj->MCONF['name'], $this->pObj->MOD_SETTINGS);
         //
         // set query and sorting
         //
         $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'tx_dam.' . $TCA[$table]['ctrl']['sortby'] : 'tx_dam.title';
         if ($this->pObj->MOD_SETTINGS['tx_dam_list_list_sortField']) {
             if (in_array($this->pObj->MOD_SETTINGS['tx_dam_list_list_sortField'], $allFields)) {
                 $orderBy = 'tx_dam.' . $this->pObj->MOD_SETTINGS['tx_dam_list_list_sortField'];
                 if ($this->pObj->MOD_SETTINGS['tx_dam_list_list_sortRev']) {
                     $orderBy .= ' DESC';
                 }
             }
         }
         $queryFieldList = tx_dam_db::getMetaInfoFieldList(false, $selectedFields);
         $this->pObj->selection->qg->addSelectFields($queryFieldList);
         $this->pObj->selection->qg->addOrderBy($orderBy);
         //
         // exec query
         //
         $this->pObj->selection->addLimitToQuery();
         $res = $this->pObj->selection->execSelectionQuery();
         //
         // init iterator for query
         //
         $conf = array('table' => 'tx_dam', 'countTotal' => $this->pObj->selection->pointer->countTotal);
         if ($langCurrent > 0 and $this->pObj->MOD_SETTINGS['tx_dam_list_langOverlay'] !== 'exclusive') {
             $dbIterator = new tx_dam_iterator_db_lang_ovl($res, $conf);
             $dbIterator->initLanguageOverlay($table, $this->pObj->MOD_SETTINGS['tx_dam_list_langSelector']);
         } else {
             $dbIterator = new tx_dam_iterator_db($res, $conf);
         }
         //
         // make db list
         //
         $dblist->setDataObject($dbIterator);
         // add columns to list
         $dblist->clearColumns();
         $cc = 0;
         foreach ($selectedFields as $field) {
             $fieldLabel = is_array($TCA[$table]['columns'][$field]) ? preg_replace('#:$#', '', $LANG->sL($TCA[$table]['columns'][$field]['label'])) : '[' . $field . ']';
             $dblist->addColumn($field, $fieldLabel);
             $cc++;
             if ($cc == 1) {
                 // add control at second column
                 $dblist->addColumn('_CONTROL_', '');
                 $cc++;
             }
         }
         // enable display of action column
         $dblist->showActions = true;
         // enable display of multi actions
         $dblist->showMultiActions = $this->pObj->MOD_SETTINGS['tx_dam_list_list_showMultiActions'];
         // enable context menus
         $dblist->enableContextMenus = $this->pObj->config_checkValueEnabled('contextMenuOnListItems', true);
         // Enable/disable display of thumbnails
         $dblist->showThumbs = $this->pObj->MOD_SETTINGS['tx_dam_list_list_showThumb'];
         // Enable/disable display of AlternateBgColors
         $dblist->showAlternateBgColors = $this->pObj->config_checkValueEnabled('alternateBgColors', true);
         $dblist->setPointer($this->pObj->selection->pointer);
         $dblist->setCurrentSorting($this->pObj->MOD_SETTINGS['tx_dam_list_list_sortField'], $this->pObj->MOD_SETTINGS['tx_dam_list_list_sortRev']);
         $dblist->setParameterName('sortField', 'SET[tx_dam_list_list_sortField]');
         $dblist->setParameterName('sortRev', 'SET[tx_dam_list_list_sortRev]');
         $this->pObj->doc->JScodeArray['dblist-JsCode'] = $dblist->getJsCode();
         // todo Clipboard
         // It is set, if the clickmenu-layer is active AND the extended view is not enabled.
         #			$dblist->dontShowClipControlPanels = $CLIENT['FORMSTYLE'] && !$BE_USER->uc['disableCMlayers'];
         #$content.= '<form action="'.htmlspecialchars(t3lib_div::linkThisScript()).'" method="post" name="'.$dblist->paramName['form'].'">';
         // get all avalibale languages for the page
         if ($languageSwitch = $this->pObj->languageSwitch($langRows, intval($this->pObj->MOD_SETTINGS['tx_dam_list_langSelector']))) {
             $this->pObj->markers['LANGUAGE_SELECT'] = '<div class="languageSwitch">' . $languageSwitch . '</div>';
         } else {
             $this->pObj->markers['LANGUAGE_SELECT'] = '';
         }
         // wraps the list table with the form
         $content .= tx_dam_SCbase::getFormTag();
         $content .= $dblist->getListTable();
         $content .= '</form>';
         $fieldSelectBoxContent = $this->fieldSelectBox($table, $allFields, $selectedFields);
         $content .= $this->pObj->buttonToggleDisplay('fieldselector', $LANG->getLL('field_selector'), $fieldSelectBoxContent);
     } else {
         // no search result: showing selection box
         if ($languageSwitch = $this->pObj->languageSwitch($langRows, intval($this->pObj->MOD_SETTINGS['tx_dam_list_langSelector']))) {
             $this->pObj->markers['LANGUAGE_SELECT'] = '<div class="languageSwitch">' . $languageSwitch . '</div>';
         } else {
             $this->pObj->markers['LANGUAGE_SELECT'] = '';
         }
         // is in footer now $content .= $this->pObj->getCurrentSelectionBox();
     }
     return $content;
 }
Пример #15
0
 /**
  * Used to fetch a file list for TypoScript cObjects
  *
  *	tt_content.textpic.20.imgList >
  *	tt_content.textpic.20.imgList.cObject = USER
  *	tt_content.textpic.20.imgList.cObject {
  *		userFunc = tx_dam_divFe->fetchFileList
  *
  * @param	mixed		$content: ...
  * @param	array		$conf: ...
  * @return	string		comma list of files with path
  * @see dam_ttcontent extension
  */
 function fetchFileList($content, $conf)
 {
     $files = array();
     $filePath = $this->cObj->stdWrap($conf['additional.']['filePath'], $conf['additional.']['filePath.']);
     $fileList = trim($this->cObj->stdWrap($conf['additional.']['fileList'], $conf['additional.']['fileList.']));
     $refField = trim($this->cObj->stdWrap($conf['refField'], $conf['refField.']));
     $fileList = t3lib_div::trimExplode(',', $fileList);
     foreach ($fileList as $file) {
         if ($file) {
             $files[] = $filePath . $file;
         }
     }
     $uid = $this->cObj->data['_LOCALIZED_UID'] ? $this->cObj->data['_LOCALIZED_UID'] : $this->cObj->data['uid'];
     $refTable = $conf['refTable'] && is_array($GLOBALS['TCA'][$conf['refTable']]) ? $conf['refTable'] : 'tt_content';
     if (isset($GLOBALS['BE_USER']->workspace) && $GLOBALS['BE_USER']->workspace !== 0) {
         $workspaceRecord = $GLOBALS['TSFE']->sys_page->getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $refTable, $uid, 'uid');
         if (is_array($workspaceRecord)) {
             $uid = $workspaceRecord['uid'];
         }
     }
     $damFiles = tx_dam_db::getReferencedFiles($refTable, $uid, $refField);
     $files = array_merge($files, $damFiles['files']);
     return implode(',', $files);
 }
 /**
  * Generation of TCEform element of the type "group" for media elements.
  * This is used to select media records in eg. tt_content.
  *
  * @param	array		$PA An array with additional configuration options.
  * @param	object		$fobj TCEForms object reference
  * @return	string		The HTML code for the TCEform field
  */
 function getSingleField_typeMedia($PA, &$fObj)
 {
     global $TYPO3_CONF_VARS;
     $this->tceforms =& $PA['pObj'];
     if (!(($msg = $this->isMMForeignActive()) === true)) {
         return $this->tceforms->getSingleField_typeNone_render(array('rows' => 1), $msg);
     }
     $table = $PA['table'];
     $field = $PA['field'];
     $row = $PA['row'];
     $config = $PA['fieldConf']['config'];
     $disabled = '';
     if ($this->tceforms->renderReadonly || $config['readOnly']) {
         $disabled = ' disabled="disabled"';
     }
     $minitems = t3lib_div::intInRange($config['minitems'], 0);
     $maxitems = t3lib_div::intInRange($config['maxitems'], 0);
     if (!$maxitems) {
         $maxitems = 100000;
     }
     $this->tceforms->requiredElements[$PA['itemFormElName']] = array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field);
     $item = '';
     $item .= '<input type="hidden" name="' . $PA['itemFormElName'] . '_mul" value="' . ($config['multiple'] ? 1 : 0) . '"' . $disabled . ' />';
     $info = '';
     // Acting according to either "file" or "db" type:
     switch ((string) $config['internal_type']) {
         case 'db':
             // If the element is of the internal type "db":
             // Creating string showing allowed types:
             $tempFT_db = t3lib_div::trimExplode(',', $config['allowed'], true);
             while (list(, $theT) = each($tempFT_db)) {
                 if ($theT) {
                     $info .= '<span class="nobr">&nbsp;&nbsp;&nbsp;&nbsp;' . t3lib_iconWorks::getIconImage($theT, array(), $this->tceforms->backPath, 'align="top"') . $this->tceforms->sL($GLOBALS['TCA'][$theT]['ctrl']['title'], true) . '</span><br />';
                 }
             }
             // Creating string showing allowed types:
             $tempFT = t3lib_div::trimExplode(',', $config['allowed_types'], true);
             if (!count($tempFT)) {
                 $info .= '*';
             }
             foreach ($tempFT as $ext) {
                 if ($ext) {
                     $info .= strtoupper($ext) . ' ';
                 }
             }
             // Creating string, showing disallowed types:
             $tempFT_dis = t3lib_div::trimExplode(',', $config['disallowed_types'], true);
             if (count($tempFT_dis)) {
                 $info .= '<br />';
             }
             foreach ($tempFT_dis as $ext) {
                 if ($ext) {
                     $info .= '-' . strtoupper($ext) . ' ';
                 }
             }
             // Collectiong file items:
             $itemArray = array();
             $filesArray = array();
             if (intval($row['uid'])) {
                 $filesArray = tx_dam_db::getReferencedFiles($table, $row['uid'], $config['MM_match_fields'], $config['MM'], 'tx_dam.*');
                 foreach ($filesArray['rows'] as $row) {
                     $itemArray[] = array('table' => 'tx_dam', 'id' => $row['uid'], 'title' => $row['title'] ? $row['title'] : $row['file_name']);
                 }
             }
             $thumbsnails = $this->renderFileList($filesArray, $config['show_thumbs']);
             /*
             					// making thumbnails
             				$thumbsnails = '';
             				if ($config['show_thumbs'] AND count($filesArray))	{
             
             					foreach($filesArray['rows'] as $row)	{
             
             							// Icon
             						$absFilePath = tx_dam::file_absolutePath($row);
             						$fileExists = @file_exists($absFilePath);
             
             						$addAttrib = 'class="absmiddle"';
             						$addAttrib .= tx_dam_guiFunc::icon_getTitleAttribute($row);
             						$fileIcon = tx_dam::icon_getFileTypeImgTag($row, $addAttrib);
             
             
             							// add clickmenu
             						if ($fileExists AND !$disabled) {
             #							$fileIcon = $this->tceforms->getClickMenu($fileIcon, $absFilePath);
             							$fileIcon = $this->tceforms->getClickMenu($fileIcon, 'tx_dam', $row['uid']);
             						}
             
             						$title = t3lib_div::fixed_lgd_cs($this->tceforms->noTitle($row['title']), $this->tceforms->titleLen);
             
             						$thumb = tx_dam_image::previewImgTag($row, '', 'align="middle"');
             
             						$thumbDescr = '<div class="nobr">'.$fileIcon.$title.'<br />'.$row['file_name'].'</div>';
             
             						$thumbsnails .= '<tr><td>'.$thumb.'</td><td>'.$thumbDescr.'</td></tr>';
             					}
             					$thumbsnails = '<table border="0">'.$thumbsnails.'</table>';
             				}
             */
             // Creating the element:
             $params = array('size' => intval($config['size']), 'dontShowMoveIcons' => $maxitems <= 1, 'autoSizeMax' => t3lib_div::intInRange($config['autoSizeMax'], 0), 'maxitems' => $maxitems, 'style' => isset($config['selectedListStyle']) ? ' style="' . htmlspecialchars($config['selectedListStyle']) . '"' : ' style="' . $this->tceforms->defaultMultipleSelectorStyle . '"', 'info' => $info, 'thumbnails' => $thumbsnails, 'readOnly' => $disabled);
             // Extra parameter for DAM element browser
             $user_eb_param = $config['allowed_types'];
             $item .= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',', $tempFT_db), $itemArray, '', $params, $PA['onFocus'], $user_eb_param);
             break;
     }
     // Wizards:
     if (!$disabled) {
         $specConf = $this->tceforms->getSpecConfFromString($PA['extra'], $PA['fieldConf']['defaultExtras']);
         $altItem = '<input type="hidden" name="' . $PA['itemFormElName'] . '" value="' . htmlspecialchars($PA['itemFormElValue']) . '" />';
         $item = $this->tceforms->renderWizards(array($item, $altItem), $config['wizards'], $table, $row, $field, $PA, $PA['itemFormElName'], $specConf);
     }
     return $item;
 }
Пример #17
0
									<size>48</size>
								</config>
							</TCEforms>
					      </xmlTitle>
					    </el>
					  </ROOT>
					</T3DataStructure>
				')));
}
t3lib_extMgm::addTCAcolumns('tt_content', $tempColumns, 1);
unset($tempColumns);
// Adding soft reference keys to tt_content configuration
require_once PATH_txdam . 'binding/softref/ext_tables.php';
if (TYPO3_MODE === 'BE') {
    // this forces the DAM sysfolder to be created if not yet available
    $temp_damFolder = tx_dam_db::getPid();
    if ($TYPO3_CONF_VARS['EXTCONF']['dam']['setup']['hideMediaFolder']) {
        t3lib_extMgm::addUserTSConfig('
			options.hideRecords.pages = ' . $temp_damFolder . '
		');
    }
    // add module after 'File'
    if (!isset($TBE_MODULES['txdamM1'])) {
        $temp_TBE_MODULES = array();
        foreach ($TBE_MODULES as $key => $val) {
            if ($key === 'file') {
                $temp_TBE_MODULES[$key] = $val;
                $temp_TBE_MODULES['txdamM1'] = $val;
            } else {
                $temp_TBE_MODULES[$key] = $val;
            }
 /**
  * Set the Information of the images if mode = dam
  * 
  * @param boolean $fromCategory
  * @return boolean
  */
 protected function setDataDam($fromCategory = false, $table = 'tt_content', $uid = 0)
 {
     // clear the imageDir
     $this->imageDir = '';
     // get all fields for captions
     $damCaptionFields = t3lib_div::trimExplode(',', $this->conf['damCaptionFields'], true);
     $damDescFields = t3lib_div::trimExplode(',', $this->conf['damDescFields'], true);
     $damHrefFields = t3lib_div::trimExplode(',', $this->conf['damHrefFields'], true);
     $fieldsArray = array_merge($damCaptionFields, $damDescFields, $damHrefFields);
     $fields = NULL;
     if (count($fieldsArray) > 0) {
         foreach ($fieldsArray as $field) {
             $fields .= ',tx_dam.' . $field;
         }
     }
     if ($fromCategory === true) {
         // Get the images from dam category
         $damcategories = $this->getDamcats($this->lConf['damcategories']);
         $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(tx_dam_db::getMetaInfoFieldList() . $fields, 'tx_dam', 'tx_dam_mm_cat', 'tx_dam_cat', " AND tx_dam_cat.uid IN (" . implode(",", $damcategories) . ")", '', 'tx_dam.sorting', '');
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $images['rows'][] = $row;
         }
     } else {
         // Get the images from dam
         $images = tx_dam_db::getReferencedFiles($table, $uid, 'imagecarousel', 'tx_dam_mm_ref', tx_dam_db::getMetaInfoFieldList() . $fields, '', '', 'tx_dam_mm_ref.sorting_foreign');
     }
     if (count($images['rows']) > 0) {
         // overlay the translation
         $conf = array('sys_language_uid' => $this->sys_language_uid, 'lovl_mode' => '');
         // add image
         foreach ($images['rows'] as $key => $row) {
             $row = tx_dam_db::getRecordOverlay('tx_dam', $row, $conf);
             $absFileName = t3lib_div::getFileAbsFileName($row['file_path'] . $row['file_name']);
             $size = @getimagesize($absFileName);
             if (preg_match("/^image\\//i", $size['mime'])) {
                 // set the data
                 $this->images[] = $row['file_path'] . $row['file_name'];
                 ${$href} = '';
                 unset($href);
                 if (count($damHrefFields) > 0) {
                     foreach ($damHrefFields as $damHrefField) {
                         if (!isset($href) && trim($row[$damHrefField])) {
                             $href = $row[$damHrefField];
                             break;
                         }
                     }
                 }
                 $this->hrefs[] = $href;
                 // set the caption
                 $caption = '';
                 unset($caption);
                 if (count($damCaptionFields) > 0) {
                     if (isset($this->conf['damCaptionObject'])) {
                         foreach ($damCaptionFields as $damCaptionField) {
                             if (isset($row[$damCaptionField])) {
                                 $GLOBALS['TSFE']->register['dam_' . $damCaptionField] = $row[$damCaptionField];
                             }
                         }
                         $caption = trim($this->cObj->cObjGetSingle($this->conf['damCaptionObject'], $this->conf['damCaptionObject.']));
                         // Unset the registered values
                         foreach ($damCaptionFields as $damCaptionField) {
                             unset($GLOBALS['TSFE']->register['dam_' . $damCaptionField]);
                         }
                     } else {
                         // the old way
                         foreach ($damCaptionFields as $damCaptionField) {
                             if (!isset($caption) && trim($row[$damCaptionField])) {
                                 $caption = $row[$damCaptionField];
                                 break;
                             }
                         }
                     }
                 }
                 $this->captions[] = $caption;
                 // set the description
                 $description = '';
                 unset($description);
                 if (count($damDescFields) > 0) {
                     if (isset($this->conf['damDescObject'])) {
                         foreach ($damDescFields as $damDescField) {
                             if (isset($row[$damDescField])) {
                                 $GLOBALS['TSFE']->register['dam_' . $damDescField] = $row[$damDescField];
                             }
                         }
                         $description = trim($this->cObj->cObjGetSingle($this->conf['damDescObject'], $this->conf['damDescObject.']));
                         // Unset the registered values
                         foreach ($damDescFields as $damDescField) {
                             unset($GLOBALS['TSFE']->register['dam_' . $damDescField]);
                         }
                     } else {
                         // the old way
                         foreach ($damDescFields as $damDescField) {
                             if (!isset($description) && trim($row[$damDescField])) {
                                 $description = $row[$damDescField];
                                 break;
                             }
                         }
                     }
                 }
                 $this->description[] = $description;
             }
         }
     }
     return true;
 }
 /**
  * Return all references for the given reference data
  *
  * @param string $refTable
  * @param string $refField
  * @return array
  */
 public static function getReferences($refTable, $refUid, $refField)
 {
     require_once tx_rnbase_util_Extensions::extPath('dam') . 'lib/class.tx_dam_db.php';
     return tx_dam_db::getReferencedFiles($refTable, $refUid, $refField);
 }
 /**
  * get the images out of DAM
  *
  * @param	int		$limitImages: How many images to return; default=0 list all
  * @return	image(s)
  */
 public function getImagesDam($limitImages = 0)
 {
     // update of ian (ian@webian.it) thx!
     // check if there's a localized version of the current content object
     $uid = $this->cObj->data['uid'];
     if ($this->cObj->data['_LOCALIZED_UID']) {
         $uid = $this->cObj->data['_LOCALIZED_UID'];
     }
     $sys_language_uid = $GLOBALS['TSFE']->sys_language_content;
     // get all the files
     $images = tx_dam_db::getReferencedFiles('tt_content', $uid, 'rgsmoothgallery', 'tx_dam_mm_ref');
     // randomise and limit image items returned from images array
     if ($limitImages > 0) {
         $test = $images['files'];
         $test = $this->getSlicedRandomArray($test, 0, $limitImages);
         $images['files'] = $test;
     }
     // begin gallery
     $content .= $this->beginGallery($this->config['id'], $limitImages);
     // add image
     foreach ($images['files'] as $key => $path) {
         // get data from the single image
         $fields = 'title,description';
         $tables = 'tx_dam';
         // now i check the tx_dam table to see if there's a localization for the current DAM record (image)
         $temp_where = 'l18n_parent = ' . $key . ' AND sys_language_uid = ' . $sys_language_uid;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $tables, $temp_where);
         // if i find a localized record i overwrite the default language $key with the localized language $key
         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
             $key = $row['uid'];
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         $temp_where = 'uid = ' . $key;
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $tables, $temp_where);
         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
         // add element to slideshow
         $content .= $this->addImage($path, $row['title'], $row['description'], $this->config['showThumbs'], $path, $limitImages);
     }
     $content .= $this->endGallery();
     return $content;
 }
 /**
  * Get the stored settings from MOD_SETTINGS and set them in $this->storedSettings
  *
  * @return	void
  */
 function initStorage($uidList = '', $pidList = '')
 {
     $pidList = $pidList ? $GLOBALS['TYPO3_DB']->cleanIntList($pidList) : '';
     $pidList = $pidList ? $pidList : tx_dam_db::getPid();
     $pidList = $this->table . '.pid IN (' . $pidList . ')';
     $uidList = $uidList ? $GLOBALS['TYPO3_DB']->cleanIntList($uidList) : '';
     $uidList = $uidList ? ' AND ' . $this->table . '.uid IN (' . $uidList . ')' : '';
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $this->table, $pidList . $uidList . ' AND ' . tx_dam_db::deleteClause($this->table), '', $this->table . '.title');
     $this->storedSettings = array();
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         #$row['definition'] = t3lib_div::xml2array($row['definition']);
         $this->storedSettings[$row['uid']] = $row;
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     $this->storedSettings = $this->cleanupStorageArray($this->storedSettings);
 }
 /**
  * Move lost DAM records to the DAM sysfolder.
  * This is a maintance function.
  *
  * @param	integer		$pid If set this PID will be used as storage sysfolder for the lost folder.
  * @param	boolean		$forceAll If true (default) all DAM records will be moved not only the ony with pid=0.
  * @return	void
  */
 function collectLostRecords($pid = NULL, $forceAll = true)
 {
     $pid = $pid ? $pid : tx_dam_db::getPid();
     if ($pid) {
         $mediaTables = tx_dam::register_getEntries('mediaTable');
         $values = array('pid' => $pid);
         if ($forceAll) {
             foreach ($mediaTables as $table) {
                 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid NOT IN (' . tx_dam_sysfolder::getPidList() . ')', $values);
             }
         } else {
             foreach ($mediaTables as $table) {
                 $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, $table . '.pid=0', $values);
             }
         }
     }
 }
 /**
  * Fetches the current element
  *
  * @return	boolean
  */
 function _fetchCurrent()
 {
     if (isset($this->res[$this->currentPointer])) {
         $uid = intval($this->res[$this->currentPointer]);
         unset($this->media);
         $this->media = tx_dam::media_getByUid($uid);
         $this->currentData = $this->media->getMetaInfoArray();
         if ($this->media->isAvailable) {
             // TODO use tx_dam_media
             if (!is_null($this->currentData) and $this->table and $this->mode === 'FE') {
                 $this->currentData = tx_dam_db::getRecordOverlay($this->table, $this->currentData, array(), $this->mode);
             }
         }
         if ($this->conf['callbackFunc_currentData'] and is_callable($this->conf['callbackFunc_currentData'])) {
             call_user_func($this->conf['callbackFunc_currentData'], $this);
         }
     } else {
         unset($this->media);
         $this->currentData = NULL;
     }
 }
    /**
     * Do the file indexing
     * Read files from a directory index them and output a result table
     *
     * @return	string		HTML content
     */
    function checkIndex($indexSessionID)
    {
        global $LANG, $TYPO3_CONF_VARS;
        // makes sense? Was a hint on php.net
        ob_end_flush();
        // get session data - which might have left files stored
        $indexSession = $this->indexSessionFetch();
        $where = array();
        if ($age = intval($this->pObj->MOD_SETTINGS['tx_dam_tools_indexupdate.age'])) {
            $where['tstamp'] = 'tstamp<' . (time() - $age);
        }
        if ($indexSessionID == '' or !isset($indexSession['ID']) or !($indexSession['ID'] == $indexSessionID) or $indexSession['currentCount'] == 0) {
            $rows = tx_dam_db::getDataWhere('COUNT(uid) as count', $where);
            reset($rows);
            $row = current($rows);
            $countTotal = $row['count'];
            $indexSession = $this->indexSessionNew($countTotal);
        }
        $files_at_a_time = 200;
        $rows = tx_dam_db::getDataWhere('', $where, '', '', intval($indexSession['currentCount']) . ',' . $files_at_a_time);
        if ($rows) {
            $c = 0;
            foreach ($rows as $meta) {
                $c++;
                // increase progress bar
                $indexSession['currentCount']++;
                if (is_array($meta)) {
                    $status = tx_dam::meta_updateStatus($meta, $this->pObj->MOD_SETTINGS['tx_dam_tools_indexupdate.deleteMissing']);
                    $ctable = array();
                    switch ($status) {
                        case TXDAM_status_file_changed:
                            $ctable[] = $this->infoIcon(2);
                            break;
                        case TXDAM_status_file_missing:
                            $ctable[] = $this->infoIcon(3);
                            break;
                        default:
                            $ctable[] = $this->infoIcon(-1);
                            break;
                    }
                    $ctable[] = tx_dam::icon_getFileTypeImgTag($meta, 'align="top"') . '&nbsp;' . htmlspecialchars(t3lib_div::fixed_lgd_cs($meta['file_name'], 30));
                    $ctable[] = htmlspecialchars(t3lib_div::fixed_lgd_cs($meta['file_path'], -30));
                    $this->indexing_addTableRow($ctable);
                    $msg = $LANG->getLL('tx_dam_tools_indexupdate.updatedMessage', 1);
                    $code = sprintf($msg, $indexSession['currentCount'], $indexSession['totalFilesCount']);
                    $this->indexing_setMessage($code);
                }
                $this->indexing_progressBar($indexSession['currentCount'], $indexSession['totalFilesCount']);
                $this->indexing_flushNow();
                $this->indexSessionWrite($indexSession);
                if (($this->indexEndtime < time() or $c == $files_at_a_time) and $indexSession['currentCount'] < $indexSession['totalFilesCount']) {
                    $params = $this->pObj->addParams;
                    $params['indexSessionID'] = $indexSession['ID'];
                    echo '
						<script type="text/javascript">  window.location.href = unescape("' . t3lib_div::rawUrlEncodeJS(tx_dam_SCbase::linkThisScriptStraight($params)) . '"); </script>';
                    exit;
                }
            }
        } elseif ($indexSession['totalFilesCount'] == 0) {
            $code = $LANG->getLL('tx_dam_tools_indexupdate.no_files');
            $this->indexing_setMessage($code);
        }
        $this->indexing_finished();
        // finished - clear session
        $this->indexSessionClear();
    }
 /**
  * Finds all the DAM-records within a specific path.
  *
  * @var string $path The file path.
  * @var string $orderBy Any ordering that should be applied.
  * @var int $limit The maximum amount of objects to return.
  * @var string $additionalWhere Query string you can append to the default WHERE statement, which matches the path.
  * @return array Array of Dam objects.
  */
 public static function getByPath($path, $orderBy = '', $limit = 1000, $additionalWhere = '')
 {
     // check if this exact function call has been made before and give the cached result
     if (isset(self::$objectStorage['path'][$path][$orderBy][$limit])) {
         return self::$objectStorage['path'][$path][$orderBy][$limit];
     }
     // removes the absolute path and adds a trailing '/' if there is none
     $path = preg_replace('/' . str_replace('/', '\\/', PATH_site) . '/', '', $path);
     if (!$path) {
         return array();
         // If the path is destroyed by the preg_replace call, don't return all records globally
     }
     $rows = \tx_dam_db::getDataWhere('*', 'file_path LIKE \'' . $path . '%\'' . $additionalWhere, '', $orderBy, $limit);
     if (count($rows) > 0) {
         // dataMapper is a singleton
         $dataMapper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Mapper\\DataMapper');
         $objects = $dataMapper->map('CIC\\Cicbase\\Domain\\Model\\DigitalAsset', $rows);
         // cache the function call
         self::$objectStorage['path'][$path][$orderBy][$limit] = $objects;
         return $objects;
     }
     self::$objectStorage['path'][$path][$orderBy][$limit] = array();
     // no records found
     return array();
 }
 /**
  * Hat der DAM Eintrag noch Referenzen?
  *
  * @return 	bool
  */
 public static function damRecordHasReferences($iLocalUid, $foreign_table = '', $foreign_uid = '', $MM_ident = '', $MM_table = 'tx_dam_mm_ref', $options = array())
 {
     if (!self::isLoaded()) {
         return false;
     }
     require_once t3lib_extMgm::extPath('dam') . 'lib/class.tx_dam_db.php';
     $fields = tx_dam_db::getMetaInfoFieldList();
     $res = tx_dam_db::referencesQuery('tx_dam', $iLocalUid, $foreign_table, $foreign_uid, $MM_ident, $MM_table, $fields);
     if ($res && ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
         return true;
     }
     //else
     return false;
 }
 /**
  * Returns a part of a WHERE clause which will filter out records with start/end times or hidden/fe_groups fields set to values that should de-select them according to the current time, preview settings or user login. Definitely a frontend function.
  * THIS IS A VERY IMPORTANT FUNCTION: Basically you must add the output from this function for EVERY select query you create for selecting records of tables in your own applications - thus they will always be filtered according to the "enablefields" configured in TCA
  * Simply calls t3lib_pageSelect::enableFields() BUT will send the show_hidden flag along! This means this function will work in conjunction with the preview facilities of the frontend engine/Admin Panel.
  *
  * @param	string		The table for which to get the where clause
  * @return	string		The part of the where clause on the form " AND NOT [fieldname] AND ...". Eg. " AND hidden=0 AND starttime < 123345567"
  * @see t3lib_pageSelect::enableFields()
  */
 function enableFields($table = '')
 {
     $table = $table ? $table : $this->table;
     return tx_dam_db::enableFields($table, 'AND', $this->mode);
 }
Пример #28
0
 /**
  * Returns the icon file path for a file type icon for a given file.
  * $mimeType = tx_dam::file_getType($filename);
  *
  * @param	array		$mimeType Describes the type of a file. Can be meta record array or array from tx_dam::file_getType().
  * @param	boolean		$absolutePath If set the path to the icon is absolute. By default it's relative to typo3/ folder.
  * @param	string		$mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default.
  * @return	string		Icon image file path
  * @see tx_dam::file_getType()
  */
 function icon_getFileType($mimeType, $absolutePath = false, $mode = TYPO3_MODE)
 {
     static $iconCache = array();
     static $iconCacheRel = array();
     $iconfile = false;
     // first see if the icon is in the icon cache
     if (is_array($mimeType)) {
         if (!$absolutePath && ($cached = $iconCacheRel[$mimeType['file_type']])) {
             return $cached;
         } elseif ($cached = $iconCache[$mimeType['file_type']]) {
             $iconfile = $cached;
         } else {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode] as $pathIcons) {
                 // Check defined icons
                 $fileType = tx_dam_db::getMediaExtension($mimeType['file_type']);
                 // See if the icon is a DAM reference
                 if (t3lib_div::testInt($fileType['icon'])) {
                     $fileType['icon'] = tx_dam::file_getPathByUid($fileType['icon']);
                 }
                 if (@file_exists($fileType['icon'])) {
                     $iconfile = $fileType['icon'];
                     $cacheKey = $mimeType['file_type'];
                     $iconCache[$cacheKey] = $iconfile;
                     break;
                 }
                 // then try default PNG
                 if (@file_exists($pathIcons . $mimeType['file_type'] . '.png')) {
                     $iconfile = $pathIcons . $mimeType['file_type'] . '.png';
                     $cacheKey = $mimeType['file_type'];
                     $iconCache[$cacheKey] = $iconfile;
                     break;
                 }
                 // then go for default GIF
                 if (@file_exists($pathIcons . $mimeType['file_type'] . '.gif')) {
                     $iconfile = $pathIcons . $mimeType['file_type'] . '.gif';
                     $cacheKey = $mimeType['file_type'];
                     $iconCache[$cacheKey] = $iconfile;
                     break;
                 }
             }
             if (!$iconfile && ($mediaType = tx_dam::convert_mediaType($mimeType['media_type']))) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode] as $pathIcons) {
                     // first try PNG
                     if (@file_exists($pathIcons . 'mtype_' . $mediaType . '.png')) {
                         $iconfile = $pathIcons . 'mtype_' . $mediaType . '.png';
                         $cacheKey = '_mtype_' . $mimeType['media_type'];
                         $iconCache[$cacheKey] = $iconfile;
                         break;
                     }
                     // then go for GIF
                     if (@file_exists($pathIcons . 'mtype_' . $mediaType . '.gif')) {
                         $iconfile = $pathIcons . 'mtype_' . $mediaType . '.gif';
                         $cacheKey = '_mtype_' . $mimeType['media_type'];
                         $iconCache[$cacheKey] = $iconfile;
                         break;
                     }
                 }
             }
             if (!$iconfile) {
                 $iconfile = PATH_txdam . 'i/18/' . 'mtype_undefined.gif';
                 $cacheKey = '__undefined';
             }
         }
     }
     if (!$absolutePath) {
         $iconfile = preg_replace('#^' . preg_quote(PATH_site) . '#', '', $iconfile);
         if (TYPO3_MODE === 'BE') {
             $iconfile = '../' . $iconfile;
             $iconCacheRel[$cacheKey] = $iconfile;
         }
     }
     return $iconfile;
 }
 /**
  * Returns the title for the input record. If blank, a "no title" labele (localized) will be returned.
  * Do NOT htmlspecialchar the string from this function - has already been done.
  *
  * @param	array		The input row array (where the key "title" is used for the title)
  * @param	integer		Title length (30)
  * @return	string		The title.
  */
 function getTitleStr($row, $titleLen = 30)
 {
     $conf['sys_language_uid'] = $this->langOvlUid;
     $row = tx_dam_db::getRecordOverlay($this->table, $row, $conf);
     $title = !strcmp(trim($row['title']), '') ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title', 1) . ']</em>' : htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'], $titleLen));
     return $title;
 }
 /**
  * Fetches the current element
  *
  * @return	void
  */
 function _fetchCurrent()
 {
     if ($this->currentData = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($this->res)) {
         if (!is_null($this->currentData) and $this->table and $this->mode === 'FE') {
             $this->currentData = tx_dam_db::getRecordOverlay($this->table, $this->currentData, array(), $this->mode);
         }
         if ($this->conf['callbackFunc_currentData'] and is_callable($this->conf['callbackFunc_currentData'])) {
             call_user_func($this->conf['callbackFunc_currentData'], $this);
         }
     } else {
         $this->currentData = NULL;
     }
 }