/** * 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; } }
/** * 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; } }
/** * Fetches the meta data variant from the index by a given meta data record array. The result will have the same fields selected as the given record. * For now different languages can be fetched. * Later this function may support versions too. * * $conf = array( * 'sys_language_uid' // sys_language uid of the wanted language * 'lovl_mode' // Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but false * ) * * In FE mode sys_language_uid and lovl_mode will be get from TSFE automatically * * The return record has still the same uid. * sys_language_uid is set from the overlay record * Additionally following keys are set: * _BASE_REC_UID - the uid from the base record which is the non-overlaid record * _LOCALIZED_UID - the uid from the overlay record * * IMPORTANT * Localized records itself does NOT contain valid data except the translated content. That means the field 'file_name' for example may contain data but could be invalid. * Valid meta data is in the record with sys_language_uid=0 only! * * @param array $row Meta data record array. Must containt uid, pid and sys_language_uid * @param integer $conf Configuration array that defines the wanted overlay * @param boolean $mode TYPO3_MODE (FE, BE) * @return array Meta data array or false * @see tx_dam_db::getRecordOverlay() */ function meta_getVariant($row, $conf, $mode = TYPO3_MODE) { $row = tx_dam_db::getRecordOverlay('tx_dam', $row, $conf, $mode); return $row; }
/** * 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; }
/** * Fetches the current element * * @return void */ function _makeLanguageOverlay() { if ($this->langUid and $this->table and $this->currentData and $this->currentData[$this->languageField] != $this->langUid) { $conf['sys_language_uid'] = $this->langUid; if ($row = tx_dam_db::getRecordOverlay($this->table, $this->currentData, $conf, $this->mode)) { $this->currentData = $row; } } }
/** * connects into the tt_news to fill the 2 markers * * @param array an array of markers coming from the extension * @param array the current record of the extension * @param array the configuration coming from the extension * @param object the parent object calling this method * @return array processed marker array */ function extraItemMarkerProcessor($markerArray, $row, $lConf, &$pObj) { $this->cObj = t3lib_div::makeInstance('tslib_cObj'); // local cObj. $this->pObj =& $pObj; $this2 = $pObj; $conf = $pObj->conf; $confLinks = $conf['lonewsdownloads.']; if (!$confLinks['download_single']) { $markerArray['###LO_DOWNLOADS###'] = 'Please include static TypoScript of LONewsDownloads or remove marker. "###LO_DOWNLOADS###"'; return $markerArray; } $downloads = ''; if (t3lib_extMgm::isLoaded('dam')) { if (t3lib_extMgm::isLoaded('dam_ttnews')) { $row = $pObj->local_cObj->data; //workspaces if (isset($row['_ORIG_uid']) && $row['_ORIG_uid'] > 0) { // draft workspace $uid = $row['_ORIG_uid']; } else { // live workspace $uid = $row['uid']; } // Check for translation if ($row['_LOCALIZED_UID']) { $uid = $row['_LOCALIZED_UID']; } $damFiles = tx_dam_db::getReferencedFiles('tt_news', $uid, 'tx_damnews_dam_media'); // Thanks to Lars Trebing, Marit AG if (count($damFiles['rows']) > 0) { $overlayConf = array('sys_language_uid' => $this->sys_language_uid); foreach ($damFiles['rows'] as $fileKey => $fileRow) { $fileRow = $recordOverlay = tx_dam_db::getRecordOverlay('tx_dam', $fileRow, $overlayConf); $damFiles['rows'][$fileKey] = $fileRow; } } $files = $damFiles['files']; $fileData = $damFiles['rows']; //t3lib_div::debug($damFiles); } else { $markerArray['###LO_DOWNLOADS###'] = 'DAM not supportet, please install dam_ttnews'; return $markerArray; } } else { # Prevents output if no file was selected, thanks to Jeroen Vreuls $files = array(); if (!empty($row['news_files'])) { $files = explode(',', $row['news_files']); $lables = explode("\n", $row['tx_lonewsdownloads_downloadlabel']); $fileData = array(); foreach ($files as $key => $file) { $pathinfo = pathinfo('uploads/media/' . $file); // t3lib_div::debug($pathinfo); $lables[$key] = trim($lables[$key]); $fileData[$key]['title'] = $lables[$key] ? $lables[$key] : $pathinfo['filename']; $fileData[$key]['file_size'] = filesize('uploads/media/' . $file); $fileData[$key]['file_type'] = strtolower($pathinfo['extension']); $files[$key] = 'uploads/media/' . $file; } } } $local_cObj = t3lib_div::makeInstance('tslib_cObj'); $local_data = $this->cObj->data; $local_data = $row; if (!$confLinks['maxItems']) { $confLinks['maxItems'] = null; } if ($confLinks['start'] || $confLinks['maxItems']) { $files = array_slice($files, $confLinks['start'], $confLinks['maxItems'], true); } foreach ($files as $key => $file) { if (is_array($fileData[$key])) { foreach ($fileData[$key] as $keyD => $valueD) { $local_data['single_news_file_' . $keyD] = $valueD; } } /* $local_data['single_news_file_file_size_Byte'] = intval($local_data['single_news_file_file_size']); $local_data['single_news_file_file_size_kB'] = round($local_data['single_news_file_file_size'] / 1024); $local_data['single_news_file_file_size_MB'] = round($local_data['single_news_file_file_size'] / 1024 / 1024); if($local_data['single_news_file_file_size_MB'] > 0) { $local_data['single_news_file_file_size'] = $local_data['single_news_file_file_size_MB'].' MB'; } else if($local_data['single_news_file_file_size_kB'] > 0) { $local_data['single_news_file_file_size'] = $local_data['single_news_file_file_size_kB'].' kB'; } else { $local_data['single_news_file_file_size'] = $local_data['single_news_file_file_size_Byte'].' Byte'; } */ $local_data['single_news_file'] = $file; $local_cObj->data = $local_data; $downloads .= $local_cObj->cObjGetSingle($confLinks['download_single'], $confLinks['download_single.']); } $local_data['lodownload_list'] = $downloads; $local_cObj->data = $local_data; $markerArray['###LO_DOWNLOADS###'] = $local_cObj->cObjGetSingle($confLinks['download_list'], $confLinks['download_list.']); return $markerArray; }