function sDisplay() { global $goApp; $s = ""; $aEntries =& $this->dContent[WY_DK_GB_ENTRIES]; $dEntry = array(); $sName = $sEMail = $sMessage = $sClientIP = ""; $iTime = $iID = 0; if ($goApp->sFormFieldValue(WY_QK_GB_MAGIC, "") == WY_QV_GB_MAGIC && ($sMessage = $goApp->sFormFieldValue(WY_QK_GB_MESSAGE, ""))) { // new message arrived $sName = $goApp->sFormFieldValue(WY_QK_GB_NAME, ""); $sEMail = $goApp->sFormFieldValue(WY_QK_GB_EMAIL, ""); if (!$this->bAddEntry($sName, $sEMail, $sMessage)) { $s .= sprintf("<script type=\"text/javascript\"> alert(\"%s\"); </script>", WYTS("IPIsBlocked")); } } if ($goApp->bEditMode) { if ($goApp->sCurrentAction() == WY_QV_GB_REMOVE) { $iID = $goApp->sFormFieldValue(WY_QK_GB_ID, 0); $this->removeEntry($iID); } if ($goApp->sCurrentAction() == WY_QV_GB_BLOCK) { $sIP = $goApp->sFormFieldValue(WY_QK_GB_IP, 0); $this->blockIP($sIP); } if ($goApp->sCurrentAction() == WY_QV_GB_UNBLOCK) { $sIP = $goApp->sFormFieldValue(WY_QK_GB_IP, 0); $this->unblockIP($sIP); } } foreach ($aEntries as $dEntry) { $sName = $dEntry[WY_DK_GB_NAME]; $sEMail = $dEntry[WY_DK_GB_EMAIL]; $sMessage = $dEntry[WY_DK_GB_MESSAGE]; // backward comp.: check isset($dEntry[WY_DK_GB_IP]) $sClientIP = isset($dEntry[WY_DK_GB_IP]) ? $dEntry[WY_DK_GB_IP] : ""; $iTime = $dEntry[WY_DK_GB_TIME]; $iID = $dEntry[WY_DK_GB_ID]; $s .= "<div class='" . WY_GB_CSS_ALL . "'>"; if ($goApp->bEditMode) { $oURL = od_clone(WYURL::oCurrentURL()); $oImgURL = od_clone($goApp->oImageURL); $dEditorQuery = $this->dEditorQuery; $dEditorQuery[WY_QK_GB_ID] = $iID; $goApp->setActionInQuery($dEditorQuery, WY_QV_GB_REMOVE); $oURL->setQuery(array_merge($oURL->dQuery, $dEditorQuery)); $oLink = new WYLink($oURL, WYTS("GuestbookRemoveButton")); $oImgURL->addComponent("remove-button.gif"); $oImg = new WYImage($oImgURL); $oLink->setInnerHTML($oImg->sDisplay()); $oLink->setAttribute("onclick", "return confirm(\"" . WYTS("GuestbookRemoveConfirm") . "\");"); $s .= $oLink->sDisplay(); } $s .= "<div>"; if ($sName) { $s .= "<span class='" . WY_GB_CSS_NAME . "'>" . webyep_sHTMLEntities($sName) . "</span>"; } if ($sEMail) { $s .= ($sName ? " " : "") . "<span class='" . WY_GB_CSS_EMAIL . "'>(" . $this->_sEMailLink($sEMail) . ")</span>"; } if ($sName || $sEMail) { $s .= ", "; } $s .= "<span class='" . WY_GB_CSS_DATETIME . "'>" . WYTS("AtDate") . " " . sWYTDate($iTime) . " " . WYTS("AtTime") . " " . sWYTTime($iTime) . "</span>:</div>\n"; if ($goApp->bEditMode) { $s .= "<div class='" . WY_GB_CSS_MESSAGE . "'>"; $s .= WYTS("ClientIP") . ": "; $bIsBlocked = in_array($sClientIP, $this->dContent[WY_DK_GB_BLOCKED_IPS]); if ($sClientIP) { if (!$bIsBlocked) { $oURL = od_clone(WYURL::oCurrentURL()); $oImgURL = od_clone($goApp->oImageURL); $dEditorQuery = $this->dEditorQuery; $dEditorQuery[WY_QK_GB_IP] = $sClientIP; $goApp->setActionInQuery($dEditorQuery, WY_QV_GB_BLOCK); $oURL->setQuery($dEditorQuery); $oLink = new WYLink($oURL, WYTS("GuestbookBlockButton")); $oImgURL->addComponent("block-button.gif"); $oImg = new WYImage($oImgURL); $oImg->setAttribute("style", "vertical-align: middle"); $oLink->setInnerHTML($oImg->sDisplay()); $oLink->setAttribute("onclick", "return confirm(\"" . WYTS("GuestbookBlockConfirm") . "\");"); } $s .= $sClientIP; if (!$bIsBlocked) { $s .= " " . $oLink->sDisplay(); } } else { $s .= WYTS("unknown"); } $s .= "</div>\n"; } // make content secure: $sMessage = str_replace("<", "", $sMessage); $sMessage = str_replace(">", "", $sMessage); $s .= "<div class='" . WY_GB_CSS_MESSAGE . "'>" . WYLongTextElement::_sFormatContent($sMessage, $this->bHideEMailAddresses) . "</div>"; $s .= "</div>\n"; } if ($goApp->bEditMode && count($this->dContent[WY_DK_GB_BLOCKED_IPS])) { unset($a); $a =& $this->dContent[WY_DK_GB_BLOCKED_IPS]; $s .= "<div class='" . WY_GB_CSS_ALL . "'>"; $s .= "<strong>" . WYTS("BlockedIPs") . ":</strong><br />\n"; $oURL = od_clone(WYURL::oCurrentURL()); $dEditorQuery = $this->dEditorQuery; $goApp->setActionInQuery($dEditorQuery, WY_QV_GB_UNBLOCK); $oURL->setQuery($dEditorQuery); $oImgURL = od_clone($goApp->oImageURL); $oImgURL->addComponent("unblock-button.gif"); $oImg = new WYImage($oImgURL); $oImg->setAttribute("style", "vertical-align: middle"); foreach ($a as $sIP) { $oURL->dQuery[WY_QK_GB_IP] = $sIP; $oLink = new WYLink($oURL, WYTS("GuestbookUnBlockButton")); $oLink->setInnerHTML($oImg->sDisplay()); $oLink->setAttribute("onclick", "return confirm(\"" . WYTS("GuestbookUnBlockConfirm") . "\");"); $s .= $sIP . " " . $oLink->sDisplay() . "<br />\n"; } $s .= "</div>"; } return $s; }
function WYRichTextElement($sN, $bG, $sCSSURL, $bObfuscate) { parent::WYElement($sN, $bG); $this->sEditorPageName = "rich-text.php"; $this->iEditorWidth = 850; $this->iEditorHeight = 620; $this->sEditButtonCSSClass = "WebYepRichTextEditButton"; if ($sCSSURL) { $this->oCSSURL = new WYURL($sCSSURL); $this->oCSSURL->makeSiteRelative(); } else { $this->oCSSURL = od_nil; } $this->bObfuscate = $bObfuscate; $this->setVersion(WY_RICHTEXT_VERSION); if (!isset($this->dContent[WY_DK_CONTENT])) { // check whether a Long Text Element with same field name left some data... $oLT = new WYLongTextElement($sN, $bG, false); if ($oLT->sText() != "") { $this->dContent[WY_DK_CONTENT] = $oLT->sDisplay(); } else { $this->dContent[WY_DK_CONTENT] = ""; } } }
<?php // WebYep // (C) Objective Development Software GmbH // http://www.obdev.at $webyep_bDocumentPage = false; $webyep_sIncludePath = ".."; include_once "{$webyep_sIncludePath}/webyep.php"; include_once @webyep_sConfigValue("webyep_sIncludePath") . "/elements/WYLongTextElement.php"; include_once @webyep_sConfigValue("webyep_sIncludePath") . "/lib/WYTextArea.php"; include_once @webyep_sConfigValue("webyep_sIncludePath") . "/lib/WYEditor.php"; $bOK = false; $sResponse = WYTS("LongTextSaved"); $sHelpFile = "longtext-element.php"; $oEditor = new WYEditor(); $oElement = new WYLongTextElement($oEditor->sFieldName, $oEditor->bGlobal, ""); $oTA = new WYTextArea("TEXT", $oElement->sText()); if ($oEditor->bSave) { $oElement->setText($oTA->sText()); $oElement->save(); $bOK = true; } else { $sOnLoadScript = 'document.forms[0].TEXT.focus();'; } $goApp->outputWarningPanels(); // give App a chance to say something ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head> <title>
function _sFormatContent($sContent, $bHideEMailAddress) { // also used by guestbook as class method - do not use $this->! global $goApp, $webyep_sCharset, $webyep_bOpenFullURLsInNewWindow; $sHTMLStandard = $goApp->sHTMLStandard(); $sBR = $sHTMLStandard == "HTML" ? "<br>" : "<br />"; $aOutLines = array(); $sASCIIBullets = chr(149) . chr(183) . "+"; if ($sContent) { $sContent = str_replace("\r\n", "\n", $sContent); $sContent = str_replace("\r", "\n", $sContent); $aInLines = explode("\n", $sContent); } else { $aInLines = array(); } $sOutLine = ""; $bInLI = false; $bInTable = false; $bNL = true; $sListType = ""; $iListLevel = 0; $iNumLines = count($aInLines); $iLine = 0; $sTarget = ""; foreach ($aInLines as $sLine) { $bNL = true; $sOutLine = ""; if (preg_match("/^([*{$sASCIIBullets}]+)[ \t]+/", $sLine, $aReg) && strpos($sLine, "|") == false) { // bullet list item if (substr($aReg[1], 0, 1) == "+") { $sListType = "ol"; } else { $sListType = "ul"; } $iNewListLevel = strlen($aReg[1]); $sLine = preg_replace("/^[*{$sASCIIBullets}]+[ \t]+/", "", $sLine); if ($iNewListLevel > $iListLevel) { $sOutLine .= "\n" . "<{$sListType}>\n"; } else { if ($iNewListLevel < $iListLevel) { $sOutLine .= "</li>\n"; while ($iNewListLevel != $iListLevel) { $sOutLine .= "</{$sListType}>\n"; $sOutLine .= "</li>\n"; $iListLevel--; } } else { $sOutLine .= "</li>\n"; } } $iListLevel = $iNewListLevel; $sOutLine .= "<li>"; $bInLI = true; $bNL = false; } else { if (trim($sLine) != "" && $iListLevel > 0) { // continued bullet list item $sLine = ltrim($sLine); // strip indention $sOutLine .= "\n{$sBR} "; $bNL = false; } } $sLine = webyep_sHTMLEntities($sLine, false); $sLine = preg_replace("/<FETT ([^>]*)>/", "<strong>\\1</strong>", $sLine); $sLine = preg_replace("/<BOLD ([^>]*)>/", "<strong>\\1</strong>", $sLine); $sLine = preg_replace("/<([^>a-z:# ]*) ([^>]*)>/", "<span class='\\1'>\\2</span>", $sLine); if ($webyep_bOpenFullURLsInNewWindow) { $sTarget = " target='_blank'"; } else { $sTarget = ""; } $sLine = preg_replace("|<LINK: *http(s?)://([^ ]*) ([^>]*)>|", "<a href='HtTp\\1://\\2'{$sTarget}>\\3</a>", $sLine); $sLine = preg_replace("|<LINK: *HTTP(S?)://([^ ]*) ([^>]*)>|", "<a href='HtTp\\1://\\2'{$sTarget}>\\3</a>", $sLine); $sLine = preg_replace("|<LINK: *([^ ]*) ([^>]*)>|", "<a href='\\1'>\\2</a>", $sLine); $sLine = preg_replace("{((HTTP)|(http))://([-a-zA-Z0-9_/.~%#?=&;]+[-a-zA-Z0-9_/~%#?=&;])}", "<a href='HtTp://\\4'{$sTarget}>http://@@\\4</a>", $sLine); while (preg_match("|(.*)http://@@([-a-zA-Z0-9_/.~%]+)(.*)|", $sLine, $aReg)) { $sLine = $aReg[1] . "http://" . str_replace("/", "/­", $aReg[2]) . $aReg[3]; } $sLine = preg_replace("{((HTTPS)|(https))://([-a-zA-Z0-9_/.~%#?=&;]+[-a-zA-Z0-9_/~%#?=&;])}", "<a href='HtTpS://\\4'{$sTarget}>https://@@\\4</a>", $sLine); while (preg_match("|(.*)https://@@([-a-zA-Z0-9_/.~%]+)(.*)|", $sLine, $aReg)) { $sLine = $aReg[1] . "https://" . str_replace("/", "/­", $aReg[2]) . $aReg[3]; } if ($bHideEMailAddress) { if (preg_match("|[-a-zA-Z0-9_.]+@[-a-zA-Z0-9_.]+|", $sLine)) { $sLine = WYLongTextElement::_sFormatEMailLinks($sLine); } } else { $sLine = preg_replace('|([-a-zA-Z0-9_.]+@[-a-zA-Z0-9_.]+[-a-zA-Z0-9_])|', "<a href='mailto:\\1'>\\1</a>", $sLine); } if (preg_match('|^-+$|', $sLine)) { $sLine = "<hr style='height:1px; border-right-style:none; border-left-style:none; border-bottom-style:none;'" . ($sHTMLStandard != "HTML" ? " /" : "") . ">\n"; $bNL = false; } $sOutLine .= $sLine; if ($iListLevel > 0 && (trim($sLine) == "" || !preg_match("|[^ \t*{$sASCIIBullets}]+|", $sLine))) { // end of bullet list while ($iListLevel > 0) { $sOutLine .= "</li>\n"; $sOutLine .= "</{$sListType}>\n"; $iListLevel--; $bInLI = false; } $bNL = false; $bInLI = false; } if ($iListLevel == 0 && preg_match('/([^\\\\]\\|)|(^\\|)/', $sOutLine)) { $aCells = WYLongTextElement::_aSplitTableCells($sOutLine); $sOutLine = "<tr>\n"; foreach ($aCells as $sCell) { $sCell = trim($sCell); if ($sCell == "") { $sCell = " "; } $sOutLine .= " <td>{$sCell}</td>\n"; } $sOutLine .= "</tr>\n"; if (!$bInTable) { $sOutLine = "<table border='0' cellpadding='0' cellspacing='0'>\n" . $sOutLine; $bInTable = true; } $bNL = false; } else { if ($bInTable && !preg_match('/([^\\\\]\\|)|(^\\|)/', $sOutLine)) { $sOutLine = "</table>{$sOutLine}\n"; $bInTable = false; $bNL = false; } } $sOutLine = preg_replace('/\\\\\\|/', '|', $sOutLine); $iLine++; if ($iLine >= $iNumLines) { $bNL = false; } $aOutLines[] = $sOutLine . ($bNL ? "{$sBR}\n" : ""); } // close everything left open: //if ($bInLI) $aOutLines[] = "</li>\n"; if ($bInLI) { $aOutLines[] = "\n"; } while ($iListLevel) { $aOutLines[] .= "</{$sListType}>\n"; $iListLevel--; } if ($bInTable) { $aOutLines[] = "</table>\n"; } $sContent = join("", $aOutLines); $sContent = str_replace("{$sBR}\n.{$sBR}", $sHTMLStandard == "HTML" ? "<br clear='all'>" : "<br clear='all' />", $sContent); $sContent = str_replace("{$sBR}\n<table>", "\n<table>", $sContent); $sContent = str_replace("HtTpS", "https", $sContent); $sContent = str_replace("HtTp", "http", $sContent); return $sContent; }
/** * Liefert den HTML-Code für das GalleryElement * * Diese Methode liefert den HTML-Code, der das GalleryElement in der Webseite darstellt. * Folgende globale Variablen beeinflussen die Arbeitsweise: * - $goApp das globale Application-Objekt (gibt Auskunft über EditMode J/N, Programmpfad, Datenpfad) * - $webyep_bUseTablesForGalleries sollen Tablellen oder DIVs für die Gallerie verwendet werden? * - $webyep_iUseImageBox wird eine JavaScript-Anwendung zur Anzeige der Bilder verwendet? * - $webyep_sLiveDemoSlotID TODO description * * @return string HTML-Code des GalleryElement */ function sDisplay() { global $goApp, $webyep_bUseTablesForGalleries, $webyep_iUseImageBox, $webyep_sLiveDemoSlotID; $sHTML = ""; $iCount = count($this->_aItems()); $i = 0; $iCols = $this->iCols; $bEditMode = $goApp->bEditMode; $sTNName = ""; $oTN = $oLink = $oDetailURL = od_nil; $sText = $sFilename = ""; $sBoxName = $this->sDataFileName(false); if ($iCount == 0 && !$bEditMode) { return ""; } if ($webyep_iUseImageBox == WEBYEP_NOBOX) { $oDetailURL = od_clone($goApp->oProgramURL); $oDetailURL->addComponent("image-detail.php"); } $sHTML .= $webyep_bUseTablesForGalleries ? sprintf("<table class=\"%s\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n", WY_GALLERY_CSS_CONTAINER) : sprintf("<div class=\"%s\">\n", WY_GALLERY_CSS_CONTAINER); while ($i < $iCount || $iCount == 0 && $i == 0 && $bEditMode || $i % $iCols) { // new row? if (!($i % $iCols)) { $sHTML .= $webyep_bUseTablesForGalleries ? sprintf(" <tr%s>\n", $i < $iCols ? " class=\"" . WY_GALLERY_CSS_FIRSTROW . "\"" : "") : sprintf(" <div style=\"overflow: hidden; zoom: 1.0\" class=\"%s%s\">\n", WY_GALLERY_CSS_ROW, $i < $iCols ? " " . WY_GALLERY_CSS_FIRSTROW : ""); } $sHTML .= $webyep_bUseTablesForGalleries ? sprintf(" <td style=\"width: %dpx\"%s>", $this->iCellWidth, $i % $iCols == 0 ? " class=\"" . WY_GALLERY_CSS_FIRSTCOLUMN . "\"" : "") : sprintf(" <div style=\"float: left; width: %dpx\" class=\"%s%s\">", $this->iCellWidth, WY_GALLERY_CSS_CELL, $i % $iCols == 0 ? " " . WY_GALLERY_CSS_FIRSTCOLUMN : ""); if ($i < $iCount) { $sHTML .= sprintf("<div class=\"%s\">", WY_GALLERY_CSS_IMAGE); $sFilename = $this->sFilenameForID($i); $sText = $this->sTextForID($i); if ($sFilename) { $oTN =& $this->_oTNImage($sFilename); unset($oLink); if ($webyep_iUseImageBox == WEBYEP_LIGHTBOX) { unset($oImgURL); $oImgURL = od_clone($goApp->oDataURL); $oImgURL->addComponent($sFilename); if ($webyep_sLiveDemoSlotID) { $oImg = new WYImage($oImgURL); if (!$oImg->bExists()) { $oImgURL->removeDemoSlotID(); } } $oLink = new WYLink($oImgURL, $sText ? $this->sStripFormatting($sText) : " "); $oLink->setAttribute("rel", "lightbox[{$sBoxName}]"); $oLink->sInnerHTML = $oTN->sDisplay(); $sHTML .= $oLink->sDisplay(); } else { if ($webyep_iUseImageBox == WEBYEP_FANCYBOX) { unset($oImgURL); $oImgURL = od_clone($goApp->oDataURL); $oImgURL->addComponent($sFilename); if ($webyep_sLiveDemoSlotID) { $oImg = new WYImage($oImgURL); if (!$oImg->bExists()) { $oImgURL->removeDemoSlotID(); } } $oLink = new WYLink($oImgURL, $sText ? $this->sStripFormatting($sText) : " "); $oLink->setAttribute("rel", "fancybox_{$sBoxName}"); $oLink->setAttribute("class", "WYPopUpImage"); $oLink->sInnerHTML = $oTN->sDisplay(); $sHTML .= $oLink->sDisplay(); } else { $oDetailURL->dQuery[WY_QK_IMAGE_DETAIL] = $sFilename; $oDetailURL->dQuery[WY_QK_IMAGE_ALTTEXT] = $this->sStripFormatting($sText); $oDetailURL->dQuery[WY_QK_IMAGE_DEMOCONTENT] = $this->bDemoContent; $oLink = new WYLink(new WYURL("javascript:void(0)")); $oLink->setAttribute("onclick", sprintf("wydw=window.open(\"%s\", \"WYDetail\", \"width=%d,height=%d,status=yes,scrollbars=no,resizable=yes\"); wydw.focus();", $oDetailURL->sEURL(true, true, true), $this->iImageWidth, $this->iImageHeight)); $oLink->setToolTip(WYTS("ClickToZoom")); $oLink->sInnerHTML = $oTN->sDisplay(); $sHTML .= $oLink->sDisplay(); } } } else { if ($bEditMode) { $sHTML .= WYTS("GalleryNoImage"); } } $sHTML .= "</div>"; } if ($bEditMode && ($i < $iCount || $i == 0)) { $sHTML .= "\n<div>"; $sHTML .= $this->_sEditButtons($i < $iCount ? $i : -1); $sHTML .= "</div>"; } if ($i < $iCount) { if ($sText) { $sHTML .= sprintf("<div class=\"%s\">", WY_GALLERY_CSS_TEXT); // $sHTML .= webyep_sHTMLEntities($sText); $sHTML .= WYLongTextElement::_sFormatContent($sText, true); $sHTML .= "</div>"; } } $sHTML .= $webyep_bUseTablesForGalleries ? "</td>\n" : "</div>\n"; // /WY_GALLERY_CSS_CELL $i++; if (!($i % $iCols)) { $sHTML .= $webyep_bUseTablesForGalleries ? " </tr>\n" : " </div>\n"; } // WY_GALLERY_CSS_ROW } $sHTML .= $webyep_bUseTablesForGalleries ? "</table>\n" : "</div>\n"; // /WY_GALLERY_CSS_CONTAINER return $sHTML; }