/** * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array. * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript. This function is called by "$this->cImage($conf['file'],$conf);" from IMAGE(). * * @param string File TypoScript resource * @param array TypoScript configuration properties * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found. * @access private * @see IMAGE() */ function cImage($file, $conf) { $info = $this->getImgResource($file, $conf['file.']); //print_r($info); // added by Caspar Stuebs @ Gosign media. if (is_array($info) && (!empty($this->data['tx_goimageeditbe_croped_image']) || false)) { $editConfig = unserialize($this->data['tx_goimageeditbe_croped_image']); // render image with info from db $newFile = $this->renderGoImageEdit($info['origFile'], $editConfig ? $editConfig : array(), $conf); // create new image info $info = $this->getImgResource($newFile, $conf['file.']); } // end of add $GLOBALS['TSFE']->lastImageInfo = $info; if (is_array($info)) { $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]); $GLOBALS['TSFE']->imagesOnPage[] = $info[3]; // This array is used to collect the image-refs on the page... if (!strlen($conf['altText']) && !is_array($conf['altText.'])) { // Backwards compatible: $conf['altText'] = $conf['alttext']; $conf['altText.'] = $conf['alttext.']; } //$altParam = $this->getAltParam($conf); if (empty($conf['altText']) && empty($conf['altText.'])) { // by ELIO@GOSIGN 19-01-2011: ALT-TEXT for all cImages $altParam = empty($this->data['altText']) ? tx_dam::media_getForFile($conf['file'])->meta['alt_text'] : $this->data['altText']; $altParam = ' alt="' . $altParam . '"'; } else { $altParam = $this->getAltParam($conf); } $theValue = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix . t3lib_div::rawUrlEncodeFP($info[3])) . '" width="' . $info[0] . '" height="' . $info[1] . '"' . $this->getBorderAttr(' border="' . intval($conf['border']) . '"') . ($conf['params'] || is_array($conf['params.']) ? ' ' . $this->stdwrap($conf['params'], $conf['params.']) : '') . $altParam . ' />'; //print_r($theValue); if ($conf['linkWrap']) { $theValue = $this->linkWrap($theValue, $conf['linkWrap']); } elseif ($conf['imageLinkWrap']) { $theValue = $this->imageLinkWrap($theValue, $info['origFile'], $conf['imageLinkWrap.']); } return $this->wrap($theValue, $conf['wrap']); } }
function damify($sAbsPath) { if ($this->useDam()) { global $PAGES_TYPES; if (!isset($PAGES_TYPES)) { require_once PATH_t3lib . 'stddb/tables.php'; } $bSimulatedUser = FALSE; global $BE_USER; // Simulate a be user to allow DAM to write in DB // see http://lists.typo3.org/pipermail/typo3-project-dam/2009-October/002751.html // and http://lists.netfielders.de/pipermail/typo3-project-dam/2006-August/000481.html 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"); } } $mBefore = intval($GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"]); $GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"] = 1; tx_dam::notify_fileChanged($sAbsPath); // previous line don't work anymore for some obscure reason. // Error seems to be in tx_dam::index_autoProcess() // at line 1332 while checking config value of setup.indexing.auto // EDIT: works now, http://lists.typo3.org/pipermail/typo3-project-dam/2009-October/002749.html // EDIT2: temporarily forcing setup.indexing.auto to be active seems to be the best solution when writing this $GLOBALS["T3_VAR"]["ext"]["dam"]["config"]["mergedTSconfig."]["setup."]["indexing."]["auto"] = $mBefore; if ($bSimulatedUser === TRUE) { unset($BE_USER); unset($GLOBALS["BE_USER"]); } $oMedia = tx_dam::media_getForFile($sAbsPath); return $oMedia->meta["uid"]; } return basename($sAbsPath); }
/** * Main function of the module. Write the content to $this->content * * @return void */ function main() { global $BE_USER, $LANG, $BACK_PATH, $TYPO3_CONF_VARS, $HTTP_GET_VARS, $HTTP_POST_VARS; $access = false; $this->errorMessages = array(); $this->media = NULL; $editorList = array(); $this->actionTarget = $this->actionTarget ? $this->actionTarget : t3lib_div::linkThisScript(array('returnUrl' => $this->returnUrl, 'redirect' => $this->redirect)); // // get media that should be edited // if ($this->file) { foreach ($this->file as $key => $filename) { if (!tx_dam::access_checkFile($filename)) { $this->errorMessages['file'][] = tx_dam::file_normalizePath($filename); unset($this->file[$key]); } } if ($this->file) { $this->media = tx_dam::media_getForFile($this->file[0]); if (!$this->media->isAvailable) { $this->errorMessages['file'][] = $this->media->filename; unset($this->media); } } } elseif ($this->record and $this->defaultPid) { foreach ($this->record as $table => $uidList) { $where = array(); $where['enableFields'] = tx_dam_db::deleteClause($table); $where['pidList'] = $table . '.pid IN (' . $this->defaultPid . ')'; $where['uid'] = $table . '.uid IN (' . implode(',', $uidList) . ')'; $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', $table, implode(' AND ', $where), '', '', '', 'uid'); if ($rows) { $this->record[$table] = array_keys($rows); } else { $this->errorMessages['record'][$table] = $uidList; unset($this->record[$table]); } } if ($this->record['tx_dam']) { // reduce passed files/records to just one item // it will be done here because later editors might want to get multiple resources (eg. blending images) so we keep the infrastructure reset($this->record['tx_dam']); // just one uid $uid = current($this->record['tx_dam']); $this->media = tx_dam::media_getByUid($uid); if (!$this->media->isAvailable) { $this->errorMessages['file'][] = $this->media->filename; unset($this->media); } } } $access = ($this->hasExtObjDefined() or is_object($this->media)); // // Main // // a valid file is selected if ($access) { $success = false; // an editor is not already defined by CMD if (!$this->hasExtObjDefined() and is_object($this->media)) { if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['editorClasses'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['editorClasses'] as $idName => $classRessource) { if (is_object($editorList[$idName] = t3lib_div::getUserObj($classRessource))) { if (!$editorList[$idName]->isValid($this->media)) { unset($editorList[$idName]); } } } } if (!count($editorList)) { // error message no valid editor found for file $this->errorMessages['error'][] = sprintf($LANG->getLL('messageNoEditorFound', 1), $this->media->filename); } elseif (count($editorList) == 1) { // activate extObj $this->errorMessages['error'][] = 'TODO: activate extObj'; if (!$this->CMD) { $this->CMD = key($editorList); } $this->handleExternalFunctionValue('function', $this->CMD); } // selection of multiple editors is below } // an editor is selected if ($this->hasExtObjDefined()) { $this->checkExtObj(); // Checking for first level external objects $this->checkSubExtObj(); // Checking second level external objects } if (is_object($this->extObj)) { $this->extObjCmdInit(); // // Initialize the template object // if (!is_object($this->doc)) { $this->doc = t3lib_div::makeInstance('template'); $this->doc->backPath = $BACK_PATH; $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_edit.html'); $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css'; $this->doc->docType = 'xhtml_trans'; } // // check access // $this->actionAccess = $this->extObjAccess(); if ($access and $this->actionAccess) { $success = true; // // Output page header // $this->doc->form = '<form action="' . htmlspecialchars($this->actionTarget) . '" method="post" name="editform" enctype="' . $TYPO3_CONF_VARS['SYS']['form_enctype'] . '">'; $this->doc->form .= '<input type="hidden" name="CMD" value="' . $this->CMD . '" />'; // JavaScript $this->doc->JScodeArray['jumpToUrl'] = ' var script_ended = 0; var changed = 0; function jumpToUrl(URL) { document.location.href = URL; } function jumpBack() { document.location.href = "' . htmlspecialchars($this->redirect) . '"; } function navFrameReload() { if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) { // top.content.nav_frame.refresh_nav(); } } '; $this->doc->postCode .= $this->doc->wrapScriptTags(' script_ended = 1;'); $this->makePageHeader(); // // Call submodule function // $this->extObjContent(); $this->markers['CONTENT'] = $this->content; } else { $access = false; $this->errorMessages['error'][] = sprintf($LANG->getLL('messageCmdDenied', true), $this->pageTitle); } } } if (!is_object($this->doc)) { $this->doc = t3lib_div::makeInstance('template'); $this->doc->backPath = $BACK_PATH; $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('dam') . 'res/templates/mod_edit.html'); $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath('dam') . 'res/css/stylesheet.css'; $this->doc->docType = 'xhtml_trans'; } // provide a selector when multiple editors are available if ($access and count($editorList) > 1) { $this->makePageHeader(); $messages = array(); $messages[] = '<div style="margin: 1em 3em 2em 3em;">' . sprintf($LANG->getLL('messageAvailableEditors', true), $this->media->filename) . '</div>'; $messages[] = '<div style="padding-left:3em; display:table-cell">'; foreach ($editorList as $idName => $editorObj) { $button = $this->button($editorObj->getIcon(), $editorObj->getLabel(), $editorObj->getDescription(), $this->actionTarget . '&CMD=' . $idName, '', ' style="display:block;"'); $messages[] = '<div style="margin-bottom:0.8em">' . $button . '</div>'; } $messages[] = '</div>'; $this->content .= $GLOBALS['SOBE']->getMessageBox($this->pageTitle, $messages, $this->buttonBack(0), 2); $success = true; } if (!$access or !$success) { // If no access $this->makePageHeader(); $messages = array(); foreach ($this->errorMessages as $type => $items) { if ($items) { if ($type !== 'error' and $headerText = $LANG->getLL($type, 1)) { $messages[] = '<h4>' . $LANG->getLL($type, true) . '</h4>'; } foreach ($items as $item) { $messages[] = '<p>' . htmlspecialchars($item) . '</p>'; } } } // file do not exist ... if (!$access) { $this->content .= $this->accessDeniedMessageBox(implode('', $messages)); } else { $this->content .= $this->errorMessageBox(implode('', $messages)); } } }
/** * tx_dam::media_getForFile() */ public function test_media_getForFile() { $fixture = $this->getFixtureRandomIndexedFilename(); $filename = $fixture['filename']; $meta = $fixture['meta']; $media = tx_dam::media_getForFile($meta); self::assertTrue(is_object($media), 'Object not created for ' . $filename); self::assertTrue($media->isIndexed); }
/** * Rendering the IMGTEXT content element, called from TypoScript (tt_content.textpic.20) * * @param string Content input. Not used, ignore. * @param array TypoScript configuration. See TSRef "IMGTEXT". This function aims to be compatible. * @return string HTML output. * @access private * @coauthor Ernesto Baschny <*****@*****.**> */ function render_textpic($content, $conf) { global $TYPO3_CONF_VARS; // Look for hook before running default code for function if (method_exists($this, 'hookRequest') && ($hookObj =& $this->hookRequest('render_textpic'))) { return $hookObj->render_textpic($content, $conf); } $renderMethod = $this->pObj->cObj->stdWrap($conf['renderMethod'], $conf['renderMethod.']); // Render using the default IMGTEXT code (table-based) if (!$renderMethod || $renderMethod == 'table') { return $this->pObj->cObj->IMGTEXT($conf); } // Specific configuration for the chosen rendering method if (is_array($conf['rendering.'][$renderMethod . '.'])) { $conf = $this->pObj->cObj->joinTSarrays($conf, $conf['rendering.'][$renderMethod . '.']); } // Image or Text with Image? if (is_array($conf['text.'])) { $content = $this->pObj->cObj->stdWrap($this->pObj->cObj->cObjGet($conf['text.'], 'text.'), $conf['text.']); } $imgList = trim($this->pObj->cObj->stdWrap($conf['imgList'], $conf['imgList.'])); if (!$imgList) { // No images, that's easy if (is_array($conf['stdWrap.'])) { return $this->pObj->cObj->stdWrap($content, $conf['stdWrap.']); } return $content; } $imgs = t3lib_div::trimExplode(',', $imgList); $imgStart = intval($this->pObj->cObj->stdWrap($conf['imgStart'], $conf['imgStart.'])); $imgCount = count($imgs) - $imgStart; $imgMax = intval($this->pObj->cObj->stdWrap($conf['imgMax'], $conf['imgMax.'])); if ($imgMax) { $imgCount = t3lib_div::intInRange($imgCount, 0, $conf['imgMax']); // reduce the number of images. } $imgPath = $this->pObj->cObj->stdWrap($conf['imgPath'], $conf['imgPath.']); if ($this->pObj->cObj->data['imagecaption_position'] == 'hidden') { $hideCaption = true; } // Global caption $caption = ''; if (!$hideCaption && !$conf['captionEach'] && !$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) { $caption = $this->pObj->cObj->stdWrap($this->pObj->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); } // Positioning $position = $this->pObj->cObj->stdWrap($conf['textPos'], $conf['textPos.']); $imagePosition = $position & 7; // 0,1,2 = center,right,left $contentPosition = $position & 24; // 0,8,16,24 (above,below,intext,intext-wrap) $align = $this->pObj->cObj->align[$imagePosition]; $textMargin = intval($this->pObj->cObj->stdWrap($conf['textMargin'], $conf['textMargin.'])); if (!$conf['textMargin_outOfText'] && $contentPosition < 16) { $textMargin = 0; } $colspacing = intval($this->pObj->cObj->stdWrap($conf['colSpace'], $conf['colSpace.'])); $rowspacing = intval($this->pObj->cObj->stdWrap($conf['rowSpace'], $conf['rowSpace.'])); $border = intval($this->pObj->cObj->stdWrap($conf['border'], $conf['border.'])) ? 1 : 0; $borderColor = $this->pObj->cObj->stdWrap($conf['borderCol'], $conf['borderCol.']); $borderThickness = intval($this->pObj->cObj->stdWrap($conf['borderThick'], $conf['borderThick.'])); $borderColor = $borderColor ? $borderColor : 'black'; $borderThickness = $borderThickness ? $borderThickness : 1; $borderSpace = $conf['borderSpace'] && $border ? intval($conf['borderSpace']) : 0; // Generate cols $cols = intval($this->pObj->cObj->stdWrap($conf['cols'], $conf['cols.'])); $colCount = $cols > 1 ? $cols : 1; if ($colCount > $imgCount) { $colCount = $imgCount; } $rowCount = ceil($imgCount / $colCount); // Generate rows $rows = intval($this->pObj->cObj->stdWrap($conf['rows'], $conf['rows.'])); if ($rows > 1) { $rowCount = $rows; if ($rowCount > $imgCount) { $rowCount = $imgCount; } $colCount = $rowCount > 1 ? ceil($imgCount / $rowCount) : $imgCount; } // Max Width $maxW = intval($this->pObj->cObj->stdWrap($conf['maxW'], $conf['maxW.'])); if ($contentPosition >= 16) { // in Text $maxWInText = intval($this->pObj->cObj->stdWrap($conf['maxWInText'], $conf['maxWInText.'])); if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 50% of the max $maxW = round($maxW / 100 * 50); } else { $maxW = $maxWInText; } } // All columns have the same width: $defaultColumnWidth = ceil(($maxW - $colspacing * ($colCount - 1) - $colCount * $border * ($borderThickness + $borderSpace) * 2) / $colCount); // Specify the maximum width for each column $columnWidths = array(); $colRelations = trim($this->pObj->cObj->stdWrap($conf['colRelations'], $conf['colRelations.'])); if (!$colRelations) { // Default 1:1-proportion, all columns same width for ($a = 0; $a < $colCount; $a++) { $columnWidths[$a] = $defaultColumnWidth; } } else { // We need another proportion $rel_parts = explode(':', $colRelations); $rel_total = 0; for ($a = 0; $a < $colCount; $a++) { $rel_parts[$a] = intval($rel_parts[$a]); $rel_total += $rel_parts[$a]; } if ($rel_total) { for ($a = 0; $a < $colCount; $a++) { $columnWidths[$a] = round($defaultColumnWidth * $colCount / $rel_total * $rel_parts[$a]); } if (min($columnWidths) <= 0 || max($rel_parts) / min($rel_parts) > 10) { // The difference in size between the largest and smalles must be within a factor of ten. for ($a = 0; $a < $colCount; $a++) { $columnWidths[$a] = $defaultColumnWidth; } } } } $image_compression = intval($this->pObj->cObj->stdWrap($conf['image_compression'], $conf['image_compression.'])); $image_effects = intval($this->pObj->cObj->stdWrap($conf['image_effects'], $conf['image_effects.'])); $image_frames = intval($this->pObj->cObj->stdWrap($conf['image_frames.']['key'], $conf['image_frames.']['key.'])); // EqualHeight $equalHeight = intval($this->pObj->cObj->stdWrap($conf['equalH'], $conf['equalH.'])); if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); $gifCreator->init(); $relations_cols = array(); for ($a = 0; $a < $imgCount; $a++) { $imgKey = $a + $imgStart; $imgInfo = $gifCreator->getImageDimensions($imgPath . $imgs[$imgKey]); $rel = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height if ($rel) { // if relations is zero, then the addition of this value is omitted as the image is not expected to display because of some error. $relations_cols[floor($a / $colCount)] += $imgInfo[0] / $rel; // counts the total width of the row with the new height taken into consideration. } } } // Fetches pictures $splitArr = array(); $splitArr['imgObjNum'] = $conf['imgObjNum']; $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount); $imageRowsFinalWidths = array(); // contains the width of every image row $imgsTag = array(); $imgsExtraData = array(); $origImages = array(); for ($a = 0; $a < $imgCount; $a++) { $imgKey = $a + $imgStart; $totalImagePath = $imgPath . $imgs[$imgKey]; $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a; $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a; $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $totalImagePath; $this->pObj->cObj->data[$this->pObj->cObj->currentValKey] = $totalImagePath; // fetch DAM data and provide it as field data prefixed with txdam_ $media = tx_dam::media_getForFile($totalImagePath, '*'); if ($media->isAvailable) { $this->addMetaToData($media->getMetaArray()); $imgsExtraData[$imgKey] = $media->getMetaArray(); } else { $this->removeMetaFromData(); $imgsExtraData[$imgKey] = array(); } unset($media); $imgObjNum = intval($splitArr[$a]['imgObjNum']); $imgConf = $conf[$imgObjNum . '.']; if ($equalHeight) { $scale = 1; $totalMaxW = $defaultColumnWidth * $colCount; $rowTotalMaxW = $relations_cols[floor($a / $colCount)]; if ($rowTotalMaxW > $totalMaxW) { $scale = $rowTotalMaxW / $totalMaxW; } // transfer info to the imageObject. Please note, that $imgConf['file.']['height'] = round($equalHeight / $scale); // other stuff will be calculated accordingly: unset($imgConf['file.']['width']); unset($imgConf['file.']['maxW']); unset($imgConf['file.']['maxH']); unset($imgConf['file.']['minW']); unset($imgConf['file.']['minH']); unset($imgConf['file.']['width.']); unset($imgConf['file.']['maxW.']); unset($imgConf['file.']['maxH.']); unset($imgConf['file.']['minW.']); unset($imgConf['file.']['minH.']); } else { $imgConf['file.']['maxW'] = $columnWidths[$a % $colCount]; } $titleInLink = $this->pObj->cObj->stdWrap($imgConf['titleInLink'], $imgConf['titleInLink.']); $titleInLinkAndImg = $this->pObj->cObj->stdWrap($imgConf['titleInLinkAndImg'], $imgConf['titleInLinkAndImg.']); $oldATagParms = $GLOBALS['TSFE']->ATagParams; if ($titleInLink) { // Title in A-tag instead of IMG-tag $titleText = trim($this->pObj->cObj->stdWrap($imgConf['titleText'], $imgConf['titleText.'])); if ($titleText) { // This will be used by the IMAGE call later: $GLOBALS['TSFE']->ATagParams .= ' title="' . $titleText . '"'; } } if ($imgConf || $imgConf['file']) { if ($this->pObj->cObj->image_effects[$image_effects]) { $imgConf['file.']['params'] .= ' ' . $this->pObj->cObj->image_effects[$image_effects]; } if ($image_frames) { if (is_array($conf['image_frames.'][$image_frames . '.'])) { $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames . '.']; } } if ($image_compression && $imgConf['file'] != 'GIFBUILDER') { if ($image_compression == 1) { $tempImport = $imgConf['file.']['import']; $tempImport_dot = $imgConf['file.']['import.']; unset($imgConf['file.']); $imgConf['file.']['import'] = $tempImport; $imgConf['file.']['import.'] = $tempImport_dot; } elseif (isset($this->pObj->cObj->image_compression[$image_compression])) { $imgConf['file.']['params'] .= ' ' . $this->pObj->cObj->image_compression[$image_compression]['params']; $imgConf['file.']['ext'] = $this->pObj->cObj->image_compression[$image_compression]['ext']; unset($imgConf['file.']['ext.']); } } if ($titleInLink && !$titleInLinkAndImg) { // Check if the image will be linked $link = $this->pObj->cObj->imageLinkWrap('', $totalImagePath, $imgConf['imageLinkWrap.']); if ($link) { // Title in A-tag only (set above: ATagParams), not in IMG-tag unset($imgConf['titleText']); unset($imgConf['titleText.']); $imgConf['emptyTitleHandling'] = 'removeAttr'; } } $imgsTag[$imgKey] = $this->pObj->cObj->IMAGE($imgConf); } else { $imgsTag[$imgKey] = $this->pObj->cObj->IMAGE(array('file' => $totalImagePath)); // currentValKey !!! } // Restore our ATagParams $GLOBALS['TSFE']->ATagParams = $oldATagParms; // Store the original filepath $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo; $imageRowsFinalWidths[floor($a / $colCount)] += $GLOBALS['TSFE']->lastImageInfo[0]; } // How much space will the image-block occupy? $imageBlockWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * ($borderSpace + $borderThickness) * 2; $GLOBALS['TSFE']->register['rowwidth'] = $imageBlockWidth; $GLOBALS['TSFE']->register['rowWidthPlusTextMargin'] = $imageBlockWidth + $textMargin; // noRows is in fact just one ROW, with the amount of columns specified, where the images are placed in. // noCols is just one COLUMN, each images placed side by side on each row $noRows = $this->pObj->cObj->stdWrap($conf['noRows'], $conf['noRows.']); $noCols = $this->pObj->cObj->stdWrap($conf['noCols'], $conf['noCols.']); if ($noRows) { $noCols = 0; } // noRows overrides noCols. They cannot exist at the same time. $rowCount_temp = 1; $colCount_temp = $colCount; if ($noRows) { $rowCount_temp = $rowCount; $rowCount = 1; } if ($noCols) { $colCount = 1; $columnWidths = array(); } // Edit icons: $editIconsHTML = $conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin ? $this->pObj->cObj->editIcons('', $conf['editIcons'], $conf['editIcons.']) : ''; // If noRows, we need multiple imagecolumn wraps $imageWrapCols = 1; if ($noRows) { $imageWrapCols = $colCount; } // User wants to separate the rows, but only do that if we do have rows $separateRows = $this->pObj->cObj->stdWrap($conf['separateRows'], $conf['separateRows.']); if ($noRows) { $separateRows = 0; } if ($rowCount == 1) { $separateRows = 0; } // Apply optionSplit to the list of classes that we want to add to each image $addClassesImage = $conf['addClassesImage']; if ($conf['addClassesImage.']) { $addClassesImage = $this->pObj->cObj->stdWrap($conf['addClassesImage'], $conf['addClassesImage.']); } $addClassesImageConf = $GLOBALS['TSFE']->tmpl->splitConfArray(array('addClassesImage' => $addClassesImage), $colCount); // Render the images $images = ''; for ($c = 0; $c < $imageWrapCols; $c++) { $tmpColspacing = $colspacing; if ($c == $imageWrapCols - 1 && $imagePosition == 2 || $c == 0 && ($imagePosition == 1 || $imagePosition == 0)) { // Do not add spacing after column if we are first column (left) or last column (center/right) $tmpColspacing = 0; } $thisImages = ''; $allRows = ''; $maxImageSpace = 0; for ($i = $c; $i < count($imgsTag); $i = $i + $imageWrapCols) { $colPos = $i % $colCount; if ($separateRows && $colPos == 0) { $thisRow = ''; } $this->addMetaToData($imgsExtraData[$i]); // Render one image $imageSpace = $origImages[$i][0] + $border * ($borderSpace + $borderThickness) * 2; $GLOBALS['TSFE']->register['IMAGE_NUM'] = $i; $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $i; $GLOBALS['TSFE']->register['ORIG_FILENAME'] = $origImages[$i]['origFile']; $GLOBALS['TSFE']->register['imagewidth'] = $origImages[$i][0]; $GLOBALS['TSFE']->register['imagespace'] = $imageSpace; $GLOBALS['TSFE']->register['imageheight'] = $origImages[$i][1]; if ($imageSpace > $maxImageSpace) { $maxImageSpace = $imageSpace; } $thisImage = ''; $thisImage .= $this->pObj->cObj->stdWrap($imgsTag[$i], $conf['imgTagStdWrap.']); if (!$hideCaption && ($conf['captionEach'] || $conf['captionSplit'] || $conf['imageTextSplit'])) { $thisCaption = $this->pObj->cObj->stdWrap($this->pObj->cObj->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); $thisImage .= $thisCaption; } if ($editIconsHTML) { $thisImage .= $this->pObj->cObj->stdWrap($editIconsHTML, $conf['editIconsStdWrap.']); } if ($conf['netprintApplicationLink']) { $thisImage .= $this->pObj->cObj->netprintApplication_offsiteLinkWrap($thisImage, $origImages[$i], $conf['netprintApplicationLink.']); } $thisImage = $this->pObj->cObj->stdWrap($thisImage, $conf['oneImageStdWrap.']); $classes = ''; if ($addClassesImageConf[$colPos]['addClassesImage']) { $classes = ' ' . $addClassesImageConf[$colPos]['addClassesImage']; } $thisImage = str_replace('###CLASSES###', $classes, $thisImage); if ($separateRows) { $thisRow .= $thisImage; } else { $allRows .= $thisImage; } $GLOBALS['TSFE']->register['columnwidth'] = $maxImageSpace + $tmpColspacing; if ($separateRows && ($colPos == $colCount - 1 || $i + 1 == count($imgsTag))) { // Close this row at the end (colCount), or the last row at the final end $allRows .= $this->pObj->cObj->stdWrap($thisRow, $conf['imageRowStdWrap.']); } } if ($separateRows) { $thisImages .= $allRows; } else { $thisImages .= $this->pObj->cObj->stdWrap($allRows, $conf['noRowsStdWrap.']); } if ($noRows) { // Only needed to make columns, rather than rows: $images .= $this->pObj->cObj->stdWrap($thisImages, $conf['imageColumnStdWrap.']); } else { $images .= $thisImages; } } // Add the global caption, if not split if ($caption) { $images .= $caption; } // CSS-classes $captionClass = ''; $classCaptionAlign = array('center' => 'csc-textpic-caption-c', 'right' => 'csc-textpic-caption-r', 'left' => 'csc-textpic-caption-l'); $captionAlign = $this->pObj->cObj->stdWrap($conf['captionAlign'], $conf['captionAlign.']); if ($captionAlign) { $captionClass = $classCaptionAlign[$captionAlign]; } $borderClass = ''; if ($border) { $borderClass = 'csc-textpic-border'; } // Multiple classes with all properties, to be styled in CSS $class = ''; $class .= $borderClass ? ' ' . $borderClass : ''; $class .= $captionClass ? ' ' . $captionClass : ''; $class .= $equalHeight ? ' csc-textpic-equalheight' : ''; $addClasses = $this->pObj->cObj->stdWrap($conf['addClasses'], $conf['addClasses.']); $class .= $addClasses ? ' ' . $addClasses : ''; // Do we need a width in our wrap around images? $imgWrapWidth = ''; if ($position == 0 || $position == 8) { // For 'center' we always need a width: without one, the margin:auto trick won't work $imgWrapWidth = $imageBlockWidth; } if ($rowCount > 1) { // For multiple rows we also need a width, so that the images will wrap $imgWrapWidth = $imageBlockWidth; } if ($caption) { // If we have a global caption, we need the width so that the caption will wrap $imgWrapWidth = $imageBlockWidth; } // Wrap around the whole image block $GLOBALS['TSFE']->register['totalwidth'] = $imgWrapWidth; if ($imgWrapWidth) { $images = $this->pObj->cObj->stdWrap($images, $conf['imageStdWrap.']); } else { $images = $this->pObj->cObj->stdWrap($images, $conf['imageStdWrapNoWidth.']); } $output = $this->pObj->cObj->cObjGetSingle($conf['layout'], $conf['layout.']); $output = str_replace('###TEXT###', $content, $output); $output = str_replace('###IMAGES###', $images, $output); $output = str_replace('###CLASSES###', $class, $output); if ($conf['stdWrap.']) { $output = $this->pObj->cObj->stdWrap($output, $conf['stdWrap.']); } $this->removeMetaFromData(); return $output; }