/** * 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; }
/** * 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 info about the usage of a media item as reference to a given table. * * @param string $uidList Uid list of tx_dam records the references shall be fetched for * @param string $table Eg tt_content * @param mixed $MM_ident Array of field/value pairs that should match in MM table. If it is a string, it will be used as value for the field 'ident'. * @param string $fields The fields to select. Needs to be prepended with table name: tx_dam.uid, tx_dam.title * @param array $whereClauses WHERE clauses as array with associative keys (which can be used to overwrite 'enableFields') or a single one as string. * @param string $groupBy: ... * @param string $orderBy: ... * @param string $limit: Default: 1000 * @return array */ function getMediaUsageReferences($uidList, $foreign_table = '', $MM_ident = '', $fields = '', $whereClauses = array(), $groupBy = '', $orderBy = '', $limit = 1000) { $rows = array(); // References in tx_dam_mm_ref table $fields = $fields ? $fields : 'tx_dam_mm_ref.*'; $local_table = 'tx_dam'; $MM_table = 'tx_dam_mm_ref'; $res = tx_dam_db::referencesQuery($local_table, $uidList, $foreign_table, '', $MM_ident, $MM_table, $fields, $whereClauses, $groupBy, $orderBy, $limit); if ($res) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rows[] = $row; } } // References in sys_refindex table $softRef_table = 'sys_refindex'; $fields = $softRef_table . '.tablename AS tablenames, ' . $softRef_table . '.recuid AS uid_foreign, ' . $softRef_table . '.ref_uid AS uid_local, ' . $softRef_table . '.field, ' . $softRef_table . '.softref_key'; $res = tx_dam_db::softRefIndexQuery($local_table, $uidList, $foreign_table, '', $softRef_ident, $softRef_table, $fields, $whereClauses, $groupBy, $orderBy, $limit); if ($res) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rows[] = $row; } } // References in tx_dam_file_tracking table $rows = array_merge($rows, tx_dam_db::getMediaUsageUploads($uidList, '', '')); return $rows; }