renaming and cleanup

Dieser Commit ist enthalten in:
o.pinke 2025-07-28 09:08:55 +02:00
Ursprung 79a1035feb
Commit cb811303c7
6 geänderte Dateien mit 11 neuen und 1308 gelöschten Zeilen

Datei anzeigen

@ -1,8 +1,8 @@
?><?php ?><?php
/** /**
* Module cl-contactform input * Module cl-contact_form input
* *
* @package module/cl_contactform * @package module/cl_contact_form
* @author Ortwin Pinke <info@php-backoffice.de> * @author Ortwin Pinke <info@php-backoffice.de>
* *
* based on w3concepts.form.v1 from Andreas Kummer (2004-08-20) * based on w3concepts.form.v1 from Andreas Kummer (2004-08-20)

Datei anzeigen

@ -2,9 +2,9 @@
global $sess; global $sess;
/** /**
* Module cl-contactform output * Module cl-contact_form output
* *
* @package module/cl_contactform * @package module/cl_contact_form
* @author Ortwin Pinke <info@php-backoffice.de> * @author Ortwin Pinke <info@php-backoffice.de>
* *
* based on w3concepts.form.v1 from Andreas Kummer (2004-08-20) * based on w3concepts.form.v1 from Andreas Kummer (2004-08-20)
@ -20,7 +20,7 @@ if (is_readable($sFrontEndPath)) {
$captchaInstalled = true; $captchaInstalled = true;
} }
class w3form class FormGenerator
{ {
public $emailAdresses; public $emailAdresses;
@ -450,13 +450,15 @@ class w3form
} }
if (cRegistry::isBackendEditMode()) { if (cRegistry::isBackendEditMode()) {
echo "<h1>" . mi18n("Formularkonfiguration") . "</h1>"; echo "<hr>";
echo "<p>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</p>"; echo "<h3>" . mi18n("Formularkonfiguration") . "</h3>";
echo "<h4>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</h4>";
echo "CMS_HTML[100]"; echo "CMS_HTML[100]";
echo "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>"; echo "<h4>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich verschickt wurde:") . "</h4>";
echo "CMS_HTML[101]"; echo "CMS_HTML[101]";
echo "<hr>";
} else { } else {
$form = new w3form($captchaInstalled, $sess); $form = new FormGenerator($captchaInstalled, $sess);
$form->addEmailAdress("CMS_VALUE[0]"); $form->addEmailAdress("CMS_VALUE[0]");
$form->setEmailSubject("CMS_VALUE[1]"); $form->setEmailSubject("CMS_VALUE[1]");
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]"); $form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");

Datei anzeigen

@ -1,610 +0,0 @@
<?php
/**
* Project:
* Contenido Content Management System
*
* Description:
* Various derived HTML class elements especially useful
* in the input area of modules
* Simple table generation class especially useful to generate
* backend configuration table. May be used also in Frontend,
* but note the globally used variables ($cfg)
*
* Usage: Store file in client/includes folder (generate the
* includes folder, if not available). Include the file
* in your modules using
* cInclude("frontend", "includes/class.input.helper.php");
*
* @package Frontend
* @subpackage InputHelpers
* @version 2.1 (formerly known as functions.input.helper.php)
* @author Björn Behrens (HerrB), http://www.btech.de
* @copyright four for business AG <www.4fb.de>
* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
*
* $Id$:
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
// Select box with additional functions for category and article selection
class cHTMLInputSelectElement extends cHTMLSelectElement {
/**
* Constructor. Creates an HTML select field (aka "DropDown").
*
* @param string $sName Name of the element
* @param int $iWidth Width of the select element
* @param string $sID ID of the element
* @param string $bDisabled Item disabled flag (non-empty to set disabled)
* @param int $iTabIndex Tab index for form elements
* @param string $sAccesskey Key to access the field
*
* @return none
* */
function __construct($sName, $iWidth = "", $sID = "", $bDisabled = false, $iTabIndex = null, $sAccessKey = "") {
cHTMLSelectElement :: __construct($sName, $iWidth, $sID, $bDisabled, $iTabIndex, $sAccessKey);
}
/**
* Function addArticles. Adds articles to select box values.
*
* @param int $iIDCat idcat of the category to be listed
* @param bool $bColored Add color information to option elements
* @param bool $bArtOnline If true, only online articles will be added
* @param string $sSpaces Just some "&nbsp;" to show data hierarchically (used in conjunction with addCategories)
*
* @return int Number of items added
* */
function addArticles($iIDCat, $bColored = false, $bArtOnline = true, $sSpaces = "") {
global $cfg, $lang;
$oDB = new DB_Contenido;
if (is_numeric($iIDCat) && $iIDCat > 0) {
$sSQL = "SELECT tblArtLang.title AS title, tblArtLang.idartlang AS idartlang, tblCatArt.idcat AS idcat, ";
$sSQL .= "tblCatArt.idcatart AS idcatart, tblCatArt.is_start AS isstart, tblArtLang.online AS online, ";
$sSQL .= "tblCatLang.startidartlang as idstartartlang ";
$sSQL .= "FROM " . $cfg["tab"]["art_lang"] . " AS tblArtLang, " . $cfg["tab"]["cat_art"] . " AS tblCatArt, ";
$sSQL .= $cfg["tab"]["cat_lang"] . " AS tblCatLang ";
$sSQL .= "WHERE tblCatArt.idcat = '" . Contenido_Security::toInteger($iIDCat) . "' AND tblCatLang.idcat = tblCatArt.idcat AND tblCatLang.idlang = tblArtLang.idlang AND ";
if ($bArtOnline) {
$sSQL .= "tblArtLang.online = '1' AND ";
}
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' ";
if ($cfg["is_start_compatible"] == true) {
$sSQL .= "ORDER BY tblCatArt.is_start DESC, tblArtLang.title"; // Getting start article as first article
} else {
$sSQL .= "ORDER BY tblArtLang.title";
}
$oDB->query($sSQL);
$iCount = $oDB->num_rows();
if ($iCount == 0) {
return 0;
} else {
$iCounter = count($this->_options);
while ($oDB->next_record()) {
// Generate new option element
$oOption = new cHTMLOptionElement($sSpaces . "&nbsp;&nbsp;&nbsp;" . substr(urldecode($oDB->f("title")), 0, 32), $oDB->f("idcatart"));
if ($bColored) {
$bIsStartArticle = false;
if ($cfg["is_start_compatible"] == true && $oDB->f("isstart") == 1) {
// Compatible mode and "start article" flag is set
$bIsStartArticle = true;
} else if ($cfg["is_start_compatible"] != true && $oDB->f("idstartartlang") == $oDB->f("idartlang")) {
// No compatible mode and current article is start article (idstartartlang is the same for all records within a category)
$bIsStartArticle = true;
}
if ($bIsStartArticle) {
if ($oDB->f("online") == 0) {
// Start article, but offline -> red
$oOption->setStyle("color: #ff0000;");
} else {
// Start article -> blue
$oOption->setStyle("color: #0000ff;");
}
} else if ($oDB->f("online") == 0) {
// Offline article -> grey
$oOption->setStyle("color: #666666;");
}
}
// Add option element to the list
$this->addOptionElement($iCounter, $oOption);
$iCounter++;
}
return $iCount;
}
} else {
return 0;
}
}
/**
* Function addCategories. Adds category elements (optionally including articles) to select box values.
* Note: Using "with articles" adds the articles also - but the categories will get a negative value!
* There is no way to distinguish between a category id and an article id...
*
* @param int $iMaxLevel Max. level shown (to be exact: except this level)
* @param bool $bColored Add color information to option elements
* @param bool $bCatVisible If true, only add idcat as value, if cat is visible
* @param bool $bCatPublic If true, only add idcat as value, if cat is public
* @param bool $bWithArt Add also articles per category
* @param bool $bArtOnline If true, show only online articles
*
* @return int Number of items added
* */
function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true, $bWithArt = false, $bArtOnline = true) {
global $cfg, $client, $lang;
$oDB = new DB_Contenido;
$sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, ";
$sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public, tblCatTree.level AS level ";
$sSQL .= "FROM " . $cfg["tab"]["cat"] . " AS tblCat, " . $cfg["tab"]["cat_lang"] . " AS tblCatLang, ";
$sSQL .= $cfg["tab"]["cat_tree"] . " AS tblCatTree ";
$sSQL .= "WHERE tblCat.idclient = '" . Contenido_Security::escapeDB($client, $oDB) . "' AND tblCatLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' AND ";
$sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat ";
if ($iMaxLevel > 0) {
$sSQL .= "AND tblCatTree.level < '" . Contenido_Security::escapeDB($iMaxLevel, $oDB) . "' ";
}
$sSQL .= "ORDER BY tblCatTree.idtree";
$oDB->query($sSQL);
$iCount = $oDB->num_rows();
if ($iCount == 0) {
return false;
} else {
$iCounter = count($this->_options);
while ($oDB->next_record()) {
$sSpaces = "";
$sStyle = "";
$iID = $oDB->f("idcat");
for ($i = 0; $i < $oDB->f("level"); $i++) {
$sSpaces .= "&nbsp;&nbsp;&nbsp;";
}
// Generate new option element
if (($bCatVisible && $oDB->f("visible") == 0) || ($bCatPublic && $oDB->f("public") == 0)) {
// If category has to be visible or public and it isn't, don't add value
$sValue = "";
} else if ($bWithArt) {
// If article will be added, set negative idcat as value
$sValue = "-" . $iID;
} else {
// Show only categories - and everything is fine...
$sValue = $iID;
}
$oOption = new cHTMLOptionElement($sSpaces . ">&nbsp;" . urldecode($oDB->f("name")), $sValue);
// Coloring option element, restricted shows grey color
$oOption->setStyle("background-color: #EFEFEF");
if ($bColored && ($oDB->f("visible") == 0 || $oDB->f("public") == 0)) {
$oOption->setStyle("color: #666666;");
}
// Add option element to the list
$this->addOptionElement($iCounter, $oOption);
if ($bWithArt) {
$iArticles = $this->addArticles($iID, $bColored, $bArtOnline, $sSpaces);
$iCount += $iArticles;
}
$iCounter = count($this->_options);
}
}
return $iCount;
}
/**
* Function addTypesFromArt. Adds types and type ids which are available for the specified article
*
* @param int $iIDCatArt Article id
* @param string $sTypeRange Komma separated list of Contenido type ids which may be in the resulting list (e.g. '1','17','28')
*
* @return int Number of items added
* */
function addTypesFromArt($iIDCatArt, $sTypeRange = "") {
global $cfg, $lang;
$oDB = new DB_Contenido;
if (is_numeric($iIDCatArt) && $iIDCatArt > 0) {
$sSQL = "SELECT tblContent.typeid AS typeid, tblContent.idtype AS idtype, tblType.type AS type, tblType.description AS description, ";
$sSQL .= "tblContent.value AS value ";
$sSQL .= "FROM " . $cfg["tab"]["content"] . " AS tblContent, " . $cfg["tab"]["art_lang"] . " AS tblArtLang, ";
$sSQL .= $cfg["tab"]["cat_art"] . " AS tblCatArt, " . $cfg["tab"]["type"] . " AS tblType ";
$sSQL .= "WHERE tblContent.idtype = tblType.idtype AND tblContent.idartlang = tblArtLang.idartlang AND ";
$sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . Contenido_Security::escapeDB($lang, $oDB) . "' AND tblCatArt.idcatart = '" . Contenido_Security::toInteger($iIDCatArt) . "' ";
if ($sTypeRange != "") {
$sSQL .= "AND tblContent.idtype IN (" . Contenido_Security::escapeDB($sTypeRange, $oDB) . ") ";
}
$sql .= "ORDER BY tblContent.idtype, tblContent.typeid";
$oDB->query($sSQL);
$iCount = $oDB->num_rows();
if ($iCount == 0) {
return false;
} else {
while ($oDB->next_record()) {
$sTypeIdentifier = "tblData.idtype = '" . $oDB->f('idtype') . "' AND tblData.typeid = '" . $oDB->f('typeid') . "'";
// Generate new option element
$oOption = new cHTMLOptionElement($oDB->f('type') . "[" . $oDB->f('typeid') . "]: " . substr(strip_tags(urldecode($oDB->f("value"))), 0, 50), $sTypeIdentifier);
// Add option element to the list
$this->addOptionElement($sTypeIdentifier, $oOption);
}
return $iCount;
}
} else {
return false;
}
}
public function addFiles($sPath) {
$iCount = 0;
$aFiles = cDirHandler::read($sPath);
asort($aFiles);
$iCounter = count($this->_options);
foreach ($aFiles as $sValue) {
$oOption = new cHTMLOptionElement($sValue, $sValue);
$this->addOptionElement($iCounter, $oOption);
$iCounter++;
}
return count($aFiles);
}
}
class UI_Config_Table {
var $_sTplCellCode;
var $_sTplTableFile;
var $_sWidth;
var $_sBorder;
var $_sBorderColor;
var $_bSolidBorder;
var $_sPadding;
var $_aCells;
var $_aCellAlignment;
var $_aCellVAlignment;
var $_aCellColSpan;
var $_aCellClass;
var $_aRowBgColor;
var $_aRowExtra;
var $_bAddMultiSelJS;
var $_sColorLight;
var $_sColorDark;
/**
*
* @var type
*/
protected $_iRowCnt = 0;
function __construct() {
$cfg = cRegistry::getConfig();
$this->_sPadding = 2;
$this->_sBorder = 0;
$this->_sBorderColor = cRegistry::getConfigValue('color', 'table_border');
$this->_sTplCellCode = '<td align="{ALIGN}" valign="{VALIGN}" class="{CLASS}" colspan="{COLSPAN}" style="{EXTRA}white-space:nowrap;" nowrap="nowrap">' . "\n"
. '{CONTENT}' . "\n"
. '</td>' . "\n";
$this->_sTplTableFile = $cfg['path']['contenido'] . $cfg['path']['templates'] . $cfg['templates']['generic_list'];
$this->_sColorLight = cRegistry::getConfigValue('color', 'table_light');
$this->_sColorDark = cRegistry::getConfigValue('color', 'table_dark');
}
function setCellTemplate($sCode) {
$this->_sTplCellCode = $sCode;
}
function setTableTemplateFile($sPath) {
$this->_sTplTableFile = $sPath;
}
function setLightColor($sColor) {
$this->_sColorLight = $sColor;
}
function setDarkColor($sColor) {
$this->_sColorDark = $sColor;
}
function setAddMultiSelJS($bEnabled = true) {
$this->_bAddMultiSelJS = (bool) $bEnabled;
}
function setWidth($sWidth) {
$this->_sWidth = $sWidth;
}
function setPadding($sPadding) {
$this->_sPadding = $sPadding;
}
function setBorder($sBorder) {
$this->_sBorder = $sBorder;
}
function setBorderColor($sBorderColor) {
$this->_sBorderColor = $sBorderColor;
}
function setSolidBorder($bSolidBorder = true) {
$this->_bSolidBorder = (bool) $bSolidBorder;
}
function setCell($sRow, $sCell, $sContent) {
$this->_aCells[$sRow][$sCell] = $sContent;
$this->_aCellAlignment[$sRow][$sCell] = "";
}
function setCellAlignment($sRow, $sCell, $sAlignment) {
$this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
}
function setCellVAlignment($sRow, $sCell, $sAlignment) {
$this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
}
function setCellColspan($sRow, $sCell, $iColSpan) {
$this->_aCellColSpan[$sRow][$sCell] = $iColSpan;
}
function setCellClass($sRow, $sCell, $sClass) {
$this->_aCellClass[$sRow][$sCell] = $sClass;
}
function setRowBgColor($sRow, $sColor) {
$this->_aRowBgColor[$sRow] = $sColor;
}
function setRowExtra($sRow, $sExtra) {
$this->_aRowExtra[$sRow] = $sExtra;
}
function _addMultiSelJS() {
// Trick: To save multiple selections in <select>-Element, add some JS which saves the
// selection, comma separated in a hidden input field on change.
// Try ... catch prevents error messages, if function is added more than once
// if (!fncUpdateSel) in JS has not worked...
$sSkript = ' <script type="text/javascript"><!--' . "\n" .
' try {' . "\n" .
' function fncUpdateSel(sSelectBox, sStorage)' . "\n" .
' {' . "\n" .
' var sSelection = "";' . "\n" .
' var oSelectBox = document.getElementsByName(sSelectBox)[0];' . "\n" .
' var oStorage = document.getElementsByName(sStorage)[0];' . "\n" .
' ' . "\n" .
' if (oSelectBox && oStorage)' . "\n" .
' {' . "\n" .
' for (i = 0; i < oSelectBox.length; i++)' . "\n" .
' {' . "\n" .
' if(oSelectBox.options[i].selected == true)' . "\n" .
' {' . "\n" .
' if (sSelection != "")' . "\n" .
' sSelection = sSelection + ",";' . "\n" .
' sSelection = sSelection + oSelectBox.options[i].value;' . "\n" .
' }' . "\n" .
' }' . "\n" .
' oStorage.value = sSelection;' . "\n" .
' }' . "\n" .
' }' . "\n" .
' } catch (e) { }' . "\n" .
' //--></script>' . "\n";
return $sSkript;
}
/**
* increase row counter
*/
public function nextRow() {
$this->_iRowCnt++;
}
/**
* get current row count
*
* @return int row count
*/
public function getRowCount() : int {
return $this->_iRowCnt;
}
public function setRowCell(int $iCell, $mContent) {
$this->setCell($this->_iRowCnt, $iCell, $mContent);
}
public function setRowBorder(string $sWhich = 'bottom') {
$sStyle = '';
switch ($sWhich) {
case 'bottom':
$this->setRowExtra($this->_iRowCnt, 'border-bottom: 1px solid silver;');
break;
}
}
public function render($bPrint = false) {
$oTable = new Template();
$oTable->reset();
$oTable->set('s', 'CELLPADDING', $this->_sPadding);
$oTable->set('s', 'BORDER', $this->_sBorder);
$oTable->set('s', 'BORDERCOLOR', $this->_sBorderColor);
$iColCount = 0;
$bDark = false;
$sBgColor = "";
$bMultiSelJSAdded = false;
if (is_array($this->_aCells)) {
foreach ($this->_aCells as $sRow => $aCells) {
$iColCount++;
//$bDark = !$bDark;
$sLine = "";
$iCount = 0;
foreach ($aCells as $sCell => $sData) {
$sData = $this->_processContentData($sData);
$iCount++;
$sTplCell = $this->_sTplCellCode;
if ($this->_bSolidBorder) {
if ($iCount < count($aCells)) {
if ($iColCount < count($this->_aCells)) {
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-bottom: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
} else {
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-right: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
}
} else if ($iColCount < count($this->_aCells)) {
$sTplCell = str_replace('{EXTRA}', 'border: 0px; border-bottom: 1px; border-color: ' . $this->_sBorderColor . '; border-style: solid;', $sTplCell);
} else {
$sTplCell = str_replace('{EXTRA}', '', $sTplCell);
}
}
if ($this->_aCellAlignment[$sRow][$sCell] != "") {
$sTplCell = str_replace('{ALIGN}', $this->_aCellAlignment[$sRow][$sCell], $sTplCell);
} else {
$sTplCell = str_replace('{ALIGN}', 'left', $sTplCell);
}
if ($this->_aCellVAlignment[$sRow][$sCell] != "") {
$sTplCell = str_replace('{VALIGN}', $this->_aCellVAlignment[$sRow][$sCell], $sTplCell);
} else {
$sTplCell = str_replace('{VALIGN}', 'top', $sTplCell);
}
if ($this->_aCellColSpan[$sRow][$sCell] != "") {
$sTplCell = str_replace('{COLSPAN}', $this->_aCellColSpan[$sRow][$sCell], $sTplCell);
} else {
$sTplCell = str_replace('{COLSPAN}', '1', $sTplCell);
}
if ($this->_aCellClass[$sRow][$sCell] != "") {
$sTplCell = str_replace('{CLASS}', $this->_aCellClass[$sRow][$sCell], $sTplCell);
} else {
$sTplCell = str_replace('{CLASS}', 'text', $sTplCell);
}
// Multi selection javascript
if ($this->_bAddMultiSelJS) {
$sData = $this->_addMultiSelJS() . $sData;
$this->_bAddMultiSelJS = false;
}
$sTplCell = str_replace('{CONTENT}', $sData, $sTplCell);
$sLine .= $sTplCell;
}
// Row
$oTable->set('d', 'ROWS', $sLine);
if ($this->_aRowBgColor[$sRow] != "") {
$sBgColor = $this->_aRowBgColor[$sRow];
} else if ($sBgColor == $this->_sColorLight) {
$sBgColor = $this->_sColorDark;
} else {
$sBgColor = $this->_sColorLight;
}
$oTable->set('d', 'BGCOLOR', $sBgColor);
if ($this->_aRowExtra[$sRow] != "") {
$oTable->set('d', 'EXTRA', $this->_aRowExtra[$sRow]);
} else {
$oTable->set('d', 'EXTRA', '');
}
$oTable->next();
}
}
if ($this->_sWidth) {
// Table: Width
$oTable->set('s', 'EXTRA', 'width: ' . $this->_sWidth . ';');
} else {
$oTable->set('s', 'EXTRA', '');
}
$sRendered = $oTable->generate($this->_sTplTableFile, true, false);
if ($bPrint == true) {
echo $sRendered;
} else {
return $sRendered;
}
}
/**
* returns different types of content data as string
* you can use
* - string
* - object, needs to have a render method
* - array of objects and/or strings
*
* @author Ortwin Pinke
* @since 2.3.0
*
*
* @param mixed $mData
* @return string
*/
protected function _processContentData($mData): string {
if (is_string($mData)) {
return $mData;
}
$sData = '';
if (is_array($mData) && count($mData) > 0) {
foreach ($mData as $mElement) {
if (is_string($mElement)) {
$sData .= $mElement;
continue;
}
$sData .= $this->_renderObject($mElement);
}
} else {
$sData = $this->_renderObject($mData);
}
return $sData;
}
/**
* Renders an object using its render method
*
* @author Ortwin Pinke
* @since 2.3.0
*
* @param type $oObject
* @return string rendered string from object | empty string
*/
protected function _renderObject($oObject): string {
$sReturn = '';
if (is_object($oObject) && method_exists($oObject, 'render')) {
$sReturn = $oObject->render();
}
return $sReturn;
}
}

Datei anzeigen

@ -1,308 +0,0 @@
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : w3concepts.form.v1
* Author : Andreas Kummer
* Copyright : mumprecht & kummer w3concepts
* Created : 20-08-2004
* Modified : 20-08-2004
************************************************/
class w3form {
var $email, $aufgedroeselt, $form, $formularFeld;
function w3form() {
}
// PRIVATE
function sendEmail() {
$this->aufdroeseln($this->suppress('sent'));
$this->generateEmailMessage();
mail($this->email['adresses'],$this->email['subject'],$this->email['message'],"From: {$this->email['from']['name']} <{$this->email['from']['email']}>\nReply-To: {$this->email['from']['email']}\nX-Mailer: PHP/" . phpversion());
}
// PRIVATE
function aufdroeseln($aufzudroeseln,$prefix = '') {
foreach ($aufzudroeseln as $key => $value) {
if (is_array($value)) {
$this->aufdroeseln($value,$key." ");
} else {
$this->aufgedroeselt["{$prefix}{$key}"] = $value;
}
}
}
// PRIVATE
function add2Message($key,$value) {
if (strlen($key) > 25 OR strlen($value) > 54) {
$this->email['message'] .= "$key\n$value\n";
} else {
$this->email['message'] .= $key;
$this->email['message'] .= str_repeat(' ',25-strlen($key));
$this->email['message'] .= "$value\n";
}
}
// PRIVATE
function generateEmailMessage() {
if ($this->aufgedroeselt) foreach ($this->aufgedroeselt as $key => $value) {
$this->add2Message($key,$value);
}
}
// PRIVATE
function suppress() {
$suppress = func_get_args();
foreach ($_POST as $key => $value) {
if (array_search($key,$suppress) === false) $fields[$key] = $value;
}
return $fields;
}
// PUBLIC
function addEmailAdress($email) {
if (empty($this->emailAdresses)) {
$this->email['adresses'] .= "$email";
} else {
$this->email['adresses'] .= ", $email";
}
}
// PUBLIC
function setEmailSubject($subject) {
$this->email['subject'] = $subject;
}
// PUBLIC
function setEmailFrom($email,$name) {
$this->email['from']['email'] = $email;
$this->email['from']['name'] = $name;
}
// PUBLIC
function setForm($form) {
$this->form['form'] = $form;
}
// PUBLIC
function setAnswer($answer) {
$this->form['answer'] = $answer;
}
// PUBLIC
function setBackgroundError($color) {
$this->form['colorError'] = $color;
}
// PRIVATE
function formularInterpretation(&$formular) {
$felder = split('###',$formular);
for ($i=1;$i<count($felder);$i=$i+2) {
$attributte = split(';',trim($felder[$i]));
foreach ($attributte as $attribut) {
$namewert = split(':',trim($attribut));
if ($namewert[0] != 'option' && $namewert[0] != 'optionvalue') {
$feld["{$felder[$i]}"]["{$namewert[0]}"] = $namewert[1];
} else {
$feld["{$felder[$i]}"]["{$namewert[0]}"][] = $namewert[1];
}
}
}
return $feld;
}
// PRIVATE
function formularAusgabe($sent = false) {
echo '<form action="" method="post">';
echo '<input type="hidden" name="sent" value="true" />';
$formular = $this->form['form'];
$formulardaten = $this->formularInterpretation(&$formular);
$formular = split('###',$formular);
foreach ($formular as $formularteil) {
if (!empty($formulardaten["{$formularteil}"])) {
$this->formularFeld($formulardaten["{$formularteil}"],$sent);
} else {
echo $formularteil;
}
}
echo '</form>';
}
// PRIVATE
function formularFeld($attribute,$sent) {
$parameter = "name=\"{$attribute['name']}\"";
if ($sent && !$this->formularFeldKorrekt(&$attribute)) $style ="style=\"background-color:{$this->form['colorError']};\"";
switch ($attribute['type']) {
case 'select':
case 'password':
case 'text':
if (!empty($attribute['size'])) $parameter .= " size=\"{$attribute['size']}\"";
break;
}
switch ($attribute['type']) {
case 'textarea':
case 'text':
if (!empty($attribute['size'])) $parameter .= " size=\"{$attribute['size']}\"";
if (!empty($attribute['value'])) $value = $attribute['value'];
if (!empty($_POST["{$attribute['name']}"])) $value = $_POST["{$attribute['name']}"];
break;
}
switch ($attribute['type']) {
case 'text':
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
break;
case 'password':
echo "<input type=\"password\" $parameter value=\"$value\" $style />";
break;
case 'textarea':
echo "<textarea name=\"{$attribute['name']}\" cols=\"";
echo (empty($attribute['cols']))?('20'):($attribute['cols']);
echo "\" rows=\"";
echo (empty($attribute['rows']))?('2'):($attribute['rows']);
echo "\" wrap=\"virtual\" $style>$value</textarea>";
break;
case 'select':
echo "<select $parameter $style>";
for ($i=0;$i<count($attribute['option']);$i++) {
if (!empty($attribute['optionvalue'][$i])) {
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['optionvalue'][$i]) {
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
if (empty($_POST["{$attribute['name']}"]) && !empty($attribute['optionvalue'][$i]) && $attribute['optionvalue'][$i] == $attribute['value']) {
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
echo "<option value=\"{$attribute['optionvalue'][$i]}\">{$attribute['option'][$i]}</option>\n";
}
}
} else {
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['option'][$i]) {
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
if (empty($_POST["{$attribute['name']}"]) && $attribute['option'][$i] == $attribute['value']) {
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
echo "<option>{$attribute['option'][$i]}</option>\n";
}
}
}
}
echo "</select>";
break;
case 'checkbox':
$formularbezeichner = preg_split('[\[|\]]',$attribute['name']);
if ($sent) {
if ($_POST["{$formularbezeichner[0]}"]["{$formularbezeichner[1]}"] == $attribute['value']) {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
}
} else {
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
}
}
break;
case 'radio':
if (!empty($_POST["{$attribute['name']}"])) {
if ($_POST["{$attribute['name']}"] == $attribute['value']) {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" />";
}
} else {
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\"/>";
}
}
break;
}
}
// PRIVATE
function formularVollstaendig() {
$formular = $this->form['form'];
$felder = $this->formularInterpretation(&$formular);
foreach ($felder as $feld) {
if (!$this->formularFeldKorrekt(&$feld)) return false;
}
return true;
}
// PRIVATE
function success() {
$this->sendEmail();
echo $this->form['answer'];
}
// PRIVATE
function formularFeldKorrekt(&$feld) {
// prüfung, ob pflichtfeld vorhanden
if (!empty($feld['mandatory']) && $feld['mandatory'] == 'true' && empty($_POST["{$feld['name']}"])) return false;
// wenn das formularfeld kein pflichtfeld und nicht vorhanden ist, true zurück geben
if (empty($_POST["{$feld['name']}"])) return true;
// regular expression prüfungen
if (!empty($feld['valid']) && $feld['valid'] == 'simpletext' && !eregi("^[öäüéàèâêîça-z-]*$",$_POST["{$feld['name']}"])) return false;
if (!empty($feld['valid']) && $feld['valid'] == 'text' && !eregi("^[ .,;!?()öäüéàèâêîça-z-]*$",$_POST["{$feld['name']}"])) return false;
if (!empty($feld['valid']) && $feld['valid'] == 'integer' && !eregi("^[0-9]*$",$_POST["{$feld['name']}"])) return false;
if (!empty($feld['valid']) && $feld['valid'] == 'float' && !eregi("^[0-9]*[.]{0,1}[0-9]*$",$_POST["{$feld['name']}"])) return false;
if (!empty($feld['valid']) && $feld['valid'] == 'date' && !eregi("^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2}$",$_POST["{$feld['name']}"])) return false;
if (!empty($feld['valid']) && $feld['valid'] == 'email' && !eregi("^[öäüéàèâêîç_a-z0-9-]+(\.[öäüéàèâêîç_a-z0-9-]+)*@[öäüéàèâêîça-z0-9-]+(\.[öäüéàèâêîça-z0-9-]+)*$",$_POST["{$feld['name']}"])) return false;
// grössenbereich bei integer und float prüfen
if (!empty($feld['minvalue']) && $_POST["{$feld['name']}"] < $feld['minvalue']) return false;
if (!empty($feld['maxvalue']) && $_POST["{$feld['name']}"] > $feld['maxvalue']) return false;
// längenbereich bei allen typen prüfen
if (!empty($feld['minlength']) && strlen($_POST["{$feld['name']}"]) < $feld['minlength']) return false;
if (!empty($feld['maxlength']) && strlen($_POST["{$feld['name']}"]) > $feld['maxlength']) return false;
return true;
}
//PUBLIC
function process() {
if (!isset($_POST['sent'])) {
$this->formularAusgabe();
} elseif ($this->formularVollstaendig()) {
$this->success();
} else {
$this->formularAusgabe(true);
}
}
}
if ($edit) {
echo "<h1>Formularkonfiguration</h1>";
echo "<p>Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:</p>";
echo "CMS_HTML[0]";
echo "<p>Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:</p>";
echo "CMS_HTML[1]";
} else {
$formular = new w3form();
$formular->addEmailAdress("CMS_VALUE[0]");
$formular->setEmailSubject("CMS_VALUE[1]");
$formular->setEmailFrom("CMS_VALUE[2]","CMS_VALUE[3]");
$formular->setBackgroundError("CMS_VALUE[4]");
$formular->setForm("CMS_HTML[0]");
$formular->setAnswer("CMS_HTML[1]");
$formular->process();
}
?>

Datei anzeigen

@ -1,37 +0,0 @@
?><?php
/**************************************************
* CONTENIDO MODULE - INPUT
*
* Modulname : w3concepts.form.v1
* Author : Andreas Kummer
* Copyright : mumprecht & kummer w3concepts
* Created : 20-08-2004
* Modified : 20-08-2004
* Modified : 24-08-2013, Murat Purc, adapted to newer CONTENIDO (4.8) version
*************************************************/
echo "
<table cellspacing='0' cellpadding='10' border='0'>
<tr>
<td>" . mi18n("Zieladresse (alias@mydomain.com):") . "</td>
<td><input type='text' name=\"CMS_VAR[0]\" value=\"CMS_VALUE[0]\" size='30' /></td>
</tr>
<tr>
<td>" . mi18n("Betreff:") . "</td>
<td><input type='text' name=\"CMS_VAR[1]\" value=\"CMS_VALUE[1]\" size='30' /></td>
</tr>
<tr>
<td>" . mi18n("Antwortadresse (alias@mydomain.com):") . "</td>
<td><input type='text' name=\"CMS_VAR[2]\" value=\"CMS_VALUE[2]\" size='30' /></td>
</tr>
<tr>
<td>" . mi18n("Emailname (z.B. Vorname Name):") . "</td>
<td><input type='text' name=\"CMS_VAR[3]\" value=\"CMS_VALUE[3]\" size='30' /></td>
</tr>
<tr>
<td>" . mi18n("Hintergrundfarbe bei Fehlern (z.B. red):") . "</td>
<td><input type='text' name=\"CMS_VAR[4]\" value=\"CMS_VALUE[4]\" size='30' /></td>
</tr>
</table>
";

Datei anzeigen

@ -1,344 +0,0 @@
<?php
/**************************************************
* CONTENIDO MODULE - OUTPUT
*
* Modulname : w3concepts.form.v1
* Author : Andreas Kummer
* Copyright : mumprecht & kummer w3concepts
* Created : 20-08-2004
* Modified : 20-08-2004
* Modified : 24-08-2013, Murat Purc, adapted to newer CONTENIDO (4.8) and PHP (5.3/5.4) versions
*************************************************/
class w3form {
private $email;
private $unraveled = array();
private $form;
private $formField = array();
public function __construct() {
$this->email = array(
'adresses' => '',
'from' => array(
'name' => '',
'email' => ''
),
'message' => '',
'subject' => ''
);
$this->form = array(
'form' => '',
'answer' => '',
'colorError' => ''
);
}
private function sendEmail() {
$this->unravel($this->suppress('sent'));
$this->generateEmailMessage();
mail(
$this->email['adresses'],
$this->email['subject'],
$this->email['message'],
sprintf(
"From: %s <%s>\nReply-To: %s\nX-Mailer: PHP/%s",
$this->email['from']['name'],
$this->email['from']['email'],
$this->email['from']['email'],
phpversion()
)
);
}
private function unravel($toUnravel, $prefix = '') {
foreach ($toUnravel as $key => $value) {
if (is_array($value)) {
$this->unravel($value, $key . ' ');
} else {
$this->unraveled["{$prefix}{$key}"] = $value;
}
}
}
private function add2Message($key, $value) {
if (strlen($key) > 25 OR strlen($value) > 54) {
$this->email['message'] .= "$key\n$value\n";
} else {
$this->email['message'] .= $key;
$this->email['message'] .= str_repeat(' ', 25 - strlen($key));
$this->email['message'] .= "$value\n";
}
}
private function generateEmailMessage() {
if ($this->unraveled)
foreach ($this->unraveled as $key => $value) {
$this->add2Message($key, $value);
}
}
private function suppress() {
$suppress = func_get_args();
foreach ($_POST as $key => $value) {
if (array_search($key, $suppress) === false)
$fields[$key] = $value;
}
return $fields;
}
public function addEmailAdress($email) {
if (empty($this->emailAdresses)) {
$this->email['adresses'] .= "$email";
} else {
$this->email['adresses'] .= ", $email";
}
}
public function setEmailSubject($subject) {
$this->email['subject'] = $subject;
}
public function setEmailFrom($email, $name) {
$this->email['from']['email'] = $email;
$this->email['from']['name'] = $name;
}
public function setForm($form) {
$this->form['form'] = $form;
}
public function setAnswer($answer) {
$this->form['answer'] = $answer;
}
public function setBackgroundError($color) {
$this->form['colorError'] = $color;
}
public function formInterpretation(&$form) {
$fields = explode('###', $form);
$field = array();
for ($i = 1; $i < count($fields); $i = $i + 2) {
$attributte = explode(';', trim($fields[$i]));
foreach ($attributte as $attribute) {
$nameValue = explode(':', trim($attribute));
if ($nameValue[0] != 'option' && $nameValue[0] != 'optionvalue') {
$field["{$fields[$i]}"]["{$nameValue[0]}"] = $nameValue[1];
} else {
$field["{$fields[$i]}"]["{$nameValue[0]}"][] = $nameValue[1];
}
}
}
return $field;
}
public function formOutput($sent = false) {
echo '<form action="" method="POST">';
echo '<input type="hidden" name="sent" value="true" />';
$form = $this->form['form'];
$formData = $this->formInterpretation($form);
$form = explode('###', $form);
foreach ($form as $item) {
if (!empty($formData["{$item}"])) {
$this->formField($formData["{$item}"], $sent);
} else {
echo $item;
}
}
echo '</form>';
}
public function formField($attribute, $sent) {
$parameter = "name=\"{$attribute['name']}\"";
if ($sent && !$this->formFieldCorrect($attribute))
$style = "style=\"background-color:{$this->form['colorError']};\"";
switch ($attribute['type']) {
case 'select':
case 'password':
case 'text':
if (!empty($attribute['size']))
$parameter .= " size=\"{$attribute['size']}\"";
break;
}
switch ($attribute['type']) {
case 'textarea':
case 'text':
if (!empty($attribute['size']))
$parameter .= " size=\"{$attribute['size']}\"";
if (!empty($attribute['value']))
$value = $attribute['value'];
if (!empty($_POST["{$attribute['name']}"]))
$value = $_POST["{$attribute['name']}"];
break;
}
switch ($attribute['type']) {
case 'text':
echo "<input type=\"text\" $parameter value=\"$value\" $style />";
break;
case 'password':
echo "<input type=\"password\" $parameter value=\"$value\" $style />";
break;
case 'textarea':
echo "<textarea name=\"{$attribute['name']}\" cols=\"";
echo (empty($attribute['cols'])) ? ('20') : ($attribute['cols']);
echo "\" rows=\"";
echo (empty($attribute['rows'])) ? ('2') : ($attribute['rows']);
echo "\" wrap=\"virtual\" $style>$value</textarea>";
break;
case 'select':
echo "<select $parameter $style>";
for ($i = 0; $i < count($attribute['option']); $i++) {
if (!empty($attribute['optionvalue'][$i])) {
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['optionvalue'][$i]) {
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
if (empty($_POST["{$attribute['name']}"]) && !empty($attribute['optionvalue'][$i]) && $attribute['optionvalue'][$i] == $attribute['value']) {
echo "<option value=\"{$attribute['optionvalue'][$i]}\" selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
echo "<option value=\"{$attribute['optionvalue'][$i]}\">{$attribute['option'][$i]}</option>\n";
}
}
} else {
if (!empty($_POST["{$attribute['name']}"]) && $_POST["{$attribute['name']}"] == $attribute['option'][$i]) {
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
if (empty($_POST["{$attribute['name']}"]) && $attribute['option'][$i] == $attribute['value']) {
echo "<option selected=\"selected\">{$attribute['option'][$i]}</option>\n";
} else {
echo "<option>{$attribute['option'][$i]}</option>\n";
}
}
}
}
echo "</select>";
break;
case 'checkbox':
$formId = preg_split('[\[|\]]', $attribute['name']);
if ($sent) {
if ($_POST["{$formId[0]}"]["{$formId[1]}"] == $attribute['value']) {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
}
} else {
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"checkbox\" $parameter value=\"{$attribute['value']}\"/>";
}
}
break;
case 'radio':
if (!empty($_POST["{$attribute['name']}"])) {
if ($_POST["{$attribute['name']}"] == $attribute['value']) {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" />";
}
} else {
if (!empty($attribute['selected']) && $attribute['selected'] == 'true') {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\" checked=\"checked\"/>";
} else {
echo "<input type=\"radio\" $parameter value=\"{$attribute['value']}\"/>";
}
}
break;
}
}
private function formComplete() {
$form = $this->form['form'];
$fields = $this->formInterpretation($form);
foreach ($fields as $field) {
if (!$this->formFieldCorrect($field)) {
return false;
}
}
return true;
}
private function success() {
$this->sendEmail();
echo $this->form['answer'];
}
private function formFieldCorrect(&$field) {
// prüfung, ob pflichtfeld vorhanden
if (!empty($field['mandatory']) && $field['mandatory'] == 'true' && empty($_POST["{$field['name']}"]))
return false;
// wenn das formularfeld kein pflichtfeld und nicht vorhanden ist, true zurück geben
if (empty($_POST["{$field['name']}"]))
return true;
// regular expression prüfungen
if (!empty($field['valid']) && $field['valid'] == 'simpletext' && !preg_match("/^[öäüéàèâêîça-z-]*$/i", $_POST["{$field['name']}"]))
return false;
if (!empty($field['valid']) && $field['valid'] == 'text' && !preg_match("/^[ .,;!?()öäüéàèâêîça-z-]*$/i", $_POST["{$field['name']}"]))
return false;
if (!empty($field['valid']) && $field['valid'] == 'integer' && !preg_match("/^[0-9]*$/", $_POST["{$field['name']}"]))
return false;
if (!empty($field['valid']) && $field['valid'] == 'float' && !preg_match("/^[0-9]*[.]{0,1}[0-9]*$/", $_POST["{$field['name']}"]))
return false;
if (!empty($field['valid']) && $field['valid'] == 'date' && !preg_match("/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{2}$/", $_POST["{$field['name']}"]))
return false;
if (!empty($field['valid']) && $field['valid'] == 'email' && !preg_match("/^[öäüéàèâêîç_a-z0-9-]+(\.[öäüéàèâêîç_a-z0-9-]+)*@[öäüéàèâêîça-z0-9-]+(\.[öäüéàèâêîça-z0-9-]+)*$/i", $_POST["{$field['name']}"]))
return false;
// grössenbereich bei integer und float prüfen
if (!empty($field['minvalue']) && $_POST["{$field['name']}"] < $field['minvalue'])
return false;
if (!empty($field['maxvalue']) && $_POST["{$field['name']}"] > $field['maxvalue'])
return false;
// längenbereich bei allen typen prüfen
if (!empty($field['minlength']) && strlen($_POST["{$field['name']}"]) < $field['minlength'])
return false;
if (!empty($field['maxlength']) && strlen($_POST["{$field['name']}"]) > $field['maxlength'])
return false;
return true;
}
public function process() {
if (!isset($_POST['sent'])) {
$this->formOutput();
} elseif ($this->formComplete()) {
$this->success();
} else {
$this->formOutput(true);
}
}
}
if (isset($edit) && $edit) {
echo "<h1>" . mi18n("Formularkonfiguration") . "</h1>";
echo "<p>" . mi18n("Hier ist das Formular sowie der Text einzugeben, der zusammen mit dem Formular ausgegeben werden soll:") . "</p>";
echo "CMS_HTML[0]";
echo "<p>" . mi18n("Hier ist die Ausgabe einzugeben, die erscheint, wenn das Formular erfolgreich prozessiert worden ist:") . "</p>";
echo "CMS_HTML[1]";
} else {
$form = new w3form();
$form->addEmailAdress("CMS_VALUE[0]");
$form->setEmailSubject("CMS_VALUE[1]");
$form->setEmailFrom("CMS_VALUE[2]", "CMS_VALUE[3]");
$form->setBackgroundError("CMS_VALUE[4]");
$form->setForm("CMS_HTML[0]");
$form->setAnswer("CMS_HTML[1]");
$form->process();
}
?>