diff --git a/php/cl_contactform_input.php b/php/cl_contactform_input.php index d93a781..04df96e 100644 --- a/php/cl_contactform_input.php +++ b/php/cl_contactform_input.php @@ -1,4 +1,13 @@ ?> + * + * based on w3concepts.form.v1 from Andreas Kummer (2004-08-20) + * modified and adapted to Contenido 4.8 under PHP 5.x by Murat Purc (2013-08-24) + */ + cInclude('frontend', 'includes/class.input.helper.php'); $oCfgTable = new UI_Config_Table(); diff --git a/php/cl_contactform_output.php b/php/cl_contactform_output.php index 2a1ee92..2c66068 100644 --- a/php/cl_contactform_output.php +++ b/php/cl_contactform_output.php @@ -1,15 +1,12 @@ + * + * based on w3concepts.form.v1 from Andreas Kummer (2004-08-20) + * modified and adapted to Contenido 4.8 under PHP 5.x by Murat Purc (2013-08-24) + */ $sFrontEndPath = cRegistry::getClientConfig(cRegistry::getClientId())['path']['frontend'] . 'securimage' . DIRECTORY_SEPARATOR; require_once $sFrontEndPath . 'securimage.php'; diff --git a/php/class.input.helper.php b/php/class.input.helper.php new file mode 100644 index 0000000..4526bc6 --- /dev/null +++ b/php/class.input.helper.php @@ -0,0 +1,610 @@ + + * @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 " " 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 . " " . 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 .= " "; + } + + // 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 . "> " . 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 = '