public function getArticleLabel($row, $label) { $page = \PageModel::findWithDetails($row['pid']); $layout = $page->getRelated('layout'); $callback = $GLOBALS['TL_DCA']['tl_article']['list']['label']['reveal_original_label_callback']; if (is_array($callback)) { $callback[0] = \System::importStatic($callback[0]); } $label = call_user_func($callback, $row, $label); if ($layout->useRevealJs) { if ($row['revealVerticalSlide'] == 'start') { $label = '┬ ' . $label; } else { if ($row['revealVerticalSlide'] == 'stop') { $label = '┴ ' . $label; } else { $predecessors = \ArticleModel::findBy(array('pid = ?', 'sorting < ?', 'revealVerticalSlide != ?'), array($row['pid'], $row['sorting'], ''), array('order' => 'sorting DESC', 'limit' => 1)); if ($predecessors && $predecessors->revealVerticalSlide == 'start') { $successor = \ArticleModel::findOneBy(array('pid = ?', 'sorting > ?'), array($row['pid'], $row['sorting']), array('order' => 'sorting', 'limit' => 1)); if ($successor && $successor->revealVerticalSlide == 'start') { $label = '┴ ' . $label; } else { $label = '│ ' . $label; } } } } $predecessors = \ArticleModel::findBy(array('pid = ?', 'sorting < ?'), array($row['pid'], $row['sorting']), array('order' => 'sorting')); if ($predecessors) { $slide = $predecessors->count(); $page = -1; $inVertical = false; foreach ($predecessors as $predecessor) { if ($predecessor->revealVerticalSlide == 'start') { $inVertical = true; } if ($inVertical && $predecessor->revealVerticalSlide != 'start') { $page += 0.001; } else { $page = (int) ($page + 1); } if ($predecessor->revealVerticalSlide == 'stop') { $inVertical = false; } } if ($inVertical && $row['revealVerticalSlide'] != 'start') { $page += 0.001; } else { $page = (int) ($page + 1); } if ($inVertical) { $pageMain = (int) $page; $pageSub = (int) (($page - $pageMain) * 1000); $page = sprintf('%d-%d', $pageMain, $pageSub); } else { $page = (int) $page; } } else { $slide = 0; $page = 0; } $label .= ' ' . sprintf($GLOBALS['TL_LANG']['tl_article']['revealSlideNumber'], $slide, $page); } return $label; }
/** * Replace DPS Insert Tags * @param $strTag * @return bool|mixed|string */ public function replaceCustomizeInsertTags($strTag) { global $objPage; $return = false; $arrSplit = explode('::', $strTag); $db = \Database::getInstance(); $strLanguage = $GLOBALS['TL_LANGUAGE']; switch (strtolower($arrSplit[0])) { case 'dps': switch ($arrSplit[1]) { case "website": $strReturn = ""; if ($arrSplit[2] == "addressBox") { $arrFieldsPs = explode(";;", $arrSplit[3]); $strReturn .= '<div vocab="http://schema.org/" typeof="Organization">'; foreach ($arrFieldsPs as $arrFieldsP) { $strReturn .= '<p>'; $arrFieldsRows = explode(";", $arrFieldsP); foreach ($arrFieldsRows as $arrFieldsRow) { $arrFields = explode(",", $arrFieldsRow); foreach ($arrFields as $strField) { $strFieldValue = trim(\Config::get('dps_website' . ucfirst($strField))); if ($strField == "company") { $strReturn .= '<span property="name"><strong>' . $strFieldValue . '</strong></span>'; } else { $arrAttributes = array(); if ($strField == "street") { $arrAttributes[] = 'property="streetAddress"'; } elseif ($strField == "postal") { $arrAttributes[] = 'property="postalCode"'; } elseif ($strField == "city") { $arrAttributes[] = 'property="addressLocality"'; } elseif ($strField == "phone") { $arrAttributes[] = 'property="telephone"'; } elseif ($strField == "email") { $arrAttributes[] = 'property="email"'; } if (($strField == "phone" || $strField == "fax" || $strField == "mobile") && strlen($strFieldValue)) { if (!preg_match('/^[+]/', $strFieldValue) && !preg_match('/^00/', $strFieldValue)) { $country = \Config::get('dps_websiteCountry'); switch ($country) { case "at": $strReturn .= '<span ' . implode(" ", $arrAttributes) . '>+43 . ' . preg_replace('/^0/', '', $strFieldValue) . '</span>'; break; } } } elseif (($strField == "email" || $strField == "website") && strlen($strFieldValue)) { $strLink = $strFieldValue; $strAttributes = trim(implode(" ", $arrAttributes)); if ($strField == "email") { $strLink = 'mailto:' . $strLink; } else { if (!preg_match('/^http/', $strLink)) { $strLink = 'http://' . $strLink; } } if (strlen($strAttributes)) { $strAttributes = " " . trim($strAttributes); } $strReturn .= '<a href="' . $strLink . '"' . $strAttributes . '>' . $strFieldValue . '</a>'; } else { $strReturn .= '<span ' . implode(" ", $arrAttributes) . '>' . $strFieldValue . '</span> '; } } } $strReturn .= '<br>'; } $strReturn .= '</p>'; } $strReturn .= '</div>'; } else { $arrParts = explode(",", $arrSplit[2]); $strField = $arrParts[0]; $strMode = $arrParts[1]; $strAttributes = $arrParts[2]; $strReturn = trim(\Config::get('dps_website' . ucfirst($strField))); if ($strMode == "label") { \System::loadLanguageFile("tl_dps_website"); $strReturn = $GLOBALS['TL_LANG']['tl_dps_website'][$strField][0]; } else { if ($strMode == "link") { if (strlen($strReturn)) { $strLink = $strReturn; if ($strField == "email") { $strLink = 'mailto:' . $strLink; } else { if (!preg_match('/^http/', $strLink)) { $strLink = 'http://' . $strLink; } } if (strlen($strAttributes)) { $strAttributes = " " . trim($strAttributes); } $strReturn = '<a href="' . $strLink . '"' . $strAttributes . '>' . $strReturn . '</a>'; } } if (($strField == "phone" || $strField == "fax" || $strField == "mobile") && strlen($strReturn)) { if (!preg_match('/^[+]/', $strReturn) && !preg_match('/^00/', $strReturn)) { $country = \Config::get('dps_websiteCountry'); switch ($country) { case "at": $strReturn = '+43 . ' . preg_replace('/^0/', '', $strReturn); break; } } } if (($strField == "logo" || $strField == "sublogo") && $strReturn != "") { $namePrefix = $strField == "sublogo" ? "Sublogo" : "Logo"; $objFile = \FilesModel::findByUuid($strReturn); if ($objFile === null) { if (!\Validator::isUuid($strReturn)) { $strReturn = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } if (is_file(TL_ROOT . '/' . $objFile->path)) { $singleSRC = $objFile->path; $size = deserialize(\Config::get('dps_website' . $namePrefix . 'Size')); $imgSize = getimagesize(TL_ROOT . '/' . $singleSRC); $intMaxWidth = \Config::get('maxImageWidth'); // Adjust the image size if ($intMaxWidth > 0) { $arrMargin = deserialize(\Config::get('dps_website' . $namePrefix . 'Imagemargin')); // Subtract the margins before deciding whether to resize (see #6018) if (is_array($arrMargin) && $arrMargin['unit'] == 'px') { $intMaxWidth = $intMaxWidth - $arrMargin['left'] - $arrMargin['right']; } if ($size[0] > $intMaxWidth || !$size[0] && !$size[1] && $imgSize[0] > $intMaxWidth) { // See #2268 (thanks to Thyon) $ratio = $size[0] && $size[1] ? $size[1] / $size[0] : $imgSize[1] / $imgSize[0]; $size[0] = $intMaxWidth; $size[1] = floor($intMaxWidth * $ratio); } } $src = \Image::get($singleSRC, $size[0], $size[1], $size[2]); // Image dimensions if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) { $arrSize = $imgSize; $imgSize = ' ' . $imgSize[3]; } $strReturn = \Image::getHtml($src, \Config::get('dps_website' . $namePrefix . 'Alt'), $imgSize); // Image link $imageUrl = \Config::get('dps_website' . $namePrefix . 'ImageUrl'); if ($imageUrl != '' && TL_MODE == 'FE') { $attributes = ""; if (\Config::get('dps_website' . $namePrefix . 'ImageNewWindow')) { $attributes = $objPage->outputFormat == 'xhtml' ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; } $strReturn = '<a href="' . $imageUrl . '"' . $attributes . '>' . $strReturn . '</a>'; } $strReturn = $this->replaceInsertTags($strReturn); } } } } if (strlen($strReturn)) { $return = $strReturn; } break; case "platzhalter": case "insert": case "placeholder": $return = \DPS\Customize\Frontend\Module\Placeholder::getPlaceholder($arrSplit[2]); // Replace TL_JAVASCRIPT from other modules before! Helper::replaceOtherDefaultScripts(); Helper::checkForUniqueScripts(); break; case "article": switch ($arrSplit[2]) { case "topImage": case "imageTop": $objArticle = \ArticleModel::findOneBy(array('pid=?', 'inColumn=?'), array($objPage->id, "main")); if ($objArticle) { if (!$objArticle->addTopImage) { $objParentPage = \PageModel::findByPk($objPage->pid); if ($objParentPage) { $objArticle = \ArticleModel::findOneBy(array('pid=?', 'inColumn=?'), array($objParentPage->id, "main")); } } if ($objArticle->addTopImage) { $imageSRC = $objArticle->topImageSRC; $objFile = \FilesModel::findByUuid($imageSRC); if ($objFile === null) { if (!\Validator::isUuid($imageSRC)) { $strReturn = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } if (is_file(TL_ROOT . '/' . $objFile->path)) { $singleSRC = $objFile->path; $imgSize = getimagesize(TL_ROOT . '/' . $singleSRC); // $intMaxWidth = \Config::get( 'maxImageWidth' ); // $src = \Image::get($singleSRC, $imgSize[0], $imgSize[1], 'center_center'); $src = \Image::get($singleSRC, 1050, 422, 'center_center'); // Image dimensions if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($src))) !== false) { $arrSize = $imgSize; $imgSize = ' ' . $imgSize[3]; } $return = \Image::getHtml($src, '', $imgSize); // Image link // $imageUrl = \Config::get('dps_website' . $namePrefix . 'ImageUrl'); // // if ($imageUrl != '' && TL_MODE == 'FE') // { // $attributes = ""; // // if( \Config::get('dps_website' . $namePrefix . 'ImageNewWindow') ) // { // $attributes = ($objPage->outputFormat == 'xhtml') ? ' onclick="return !window.open(this.href)"' : ' target="_blank"'; // } // // $strReturn = '<a href="' . $imageUrl . '"' . $attributes . '>' . $strReturn . '</a>'; // } $return = $this->replaceInsertTags($return); } } } break; case "topImageText": case "topImageTitle": $objArticle = \ArticleModel::findOneBy(array('pid=?', 'inColumn=?'), array($objPage->id, "main")); if ($objArticle) { if (strlen($objArticle->topImageTitle)) { $return = $this->replaceInsertTags($objArticle->topImageTitle); } else { $objParentPage = \PageModel::findByPk($objPage->pid); if ($objParentPage) { $objArticle = \ArticleModel::findOneBy(array('pid=?', 'inColumn=?'), array($objParentPage->id, "main")); if (strlen($objArticle->topImageTitle)) { $return = $this->replaceInsertTags($objArticle->topImageTitle); } } } } break; } break; } break; } return $return; }