^_^
Verfasst: Do 24. Feb 2005, 01:03
^_^
Das Diskussionsforum zum Open Source Content Management System
https://www.forum.contenido.org/
Code: Alles auswählen
$cms_select = array ("left" => "Linksbündig", "right" => "Rechtsbündig", ...);
echo "CMS_SELECTEDIT[15]";
...
echo "<p align='CMS_SELECT[15]'>";
Code: Alles auswählen
/**
* CMS_ALIGN
*/
$tmp = $a_content["CMS_ALIGN"][$val];
if (!in_array($tmp, array("left", "center", "right", "justify"))) $tmp = "left";
Code: Alles auswählen
/**
* CMS_ALIGNEDIT
*/
$tmp = "";
if ($edit) {
$tmp = '<A HREF="' . $sess->url("front_content.php?action=10&" . "idcat=$idcat&idart=$idart&" . "idartlang=$idartlang&type=CMS_ALIGN&typenr=$val&lang=$lang") . '">
<IMG SRC="' . $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] . 'but_editalign.gif" border=0>
</A>';
$tmp = addslashes($tmp);
$tmp = addslashes($tmp);
}
Code: Alles auswählen
<?php
/******************************************
* File : include.CMS_ALIGN.php
* Project : Contenido
* Descr : Include file for editiing
* content of type CMS_ALIGN
******************************************/
$align_values = array("left" => "linksbündig",
"center" => "zentriert",
"right" => "rechtsbündig",
"justify" => "Blocksatz");
if ( $doedit == "1") {
if (in_array ($CMS_ALIGN, array_keys ($align_values))) {
consaveContentEntry($idartlang, "CMS_ALIGN", $typenr, $CMS_ALIGN);
conGenerateCodeForArtInAllCategories($idart);
}
header("location:".$sess->url($cfgClient[$client]["path"]["htmlpath"]."front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&changeview=edit")."");
}
getAvailableContentTypes($idartlang);
$CMS_ALIGN = $a_content["CMS_ALIGN"][$typenr];
echo '<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="'. $cfg["path"]["contenido_fullhtml"].$cfg["path"]["styles"] . 'contenido.css">
<base href="'. $cfgClient[$client]["path"]["htmlpath"]. '">
</head>
<body>
<form method="post" action="' .$cfg["path"]["contenido_fullhtml"].$cfg["path"]["includes"]. 'include.backendedit.php">
<table style="width:100%; height=100%" border=0 cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<tr>
<td>
<INPUT type=hidden name=lang value="'.$lang.'">';
$sess->hidden_session();
echo '
<INPUT type=hidden name=typenr value="'.$typenr.'">
<INPUT type=hidden name=idart value="'.$idart.'">
<INPUT type=hidden name=idcat value="'.$idcat.'">
<INPUT type=hidden name=idartlang value="'.$idartlang.'">
<INPUT type=hidden name=doedit value="1">
<INPUT type=hidden name=action value="10">
<INPUT type=hidden name=type value="'.$type.'">
<INPUT type=hidden name=changeview value="edit">
</td>
</tr><tr>
<td style="width:100%; height=100%; text-align: center;">
<table border=0 cellspacing="5" cellpadding="0" bgcolor="#ffffff">
<tr class="text_medium">
<td>Horizontale Ausrichtung:</td>
<td>
<SELECT name="CMS_ALIGN" size="1" style="width: 150px;">';
foreach ($align_values as $skey => $svalue) {
echo '
<OPTION value="'.$skey.'"'.($skey == $CMS_ALIGN ? ' selected="selected"' : '').'>'.$svalue.'</OPTION>';
}
echo '
</SELECT>
</td>
</tr>
<tr>
<td></td>
<td style="text-align: right;">
<a href="' . $sess->url($cfgClient[$client]["path"]["htmlpath"]."front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&idartlang=$idartlang") . '"><img src="' . $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] . 'but_cancel.gif" border=0 /></a>
<input type=image name=submit value=editcontent src="' . $cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"] . 'but_ok.gif" border=0 />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>';
Code: Alles auswählen
<!-- Testmodul OUTPUT -->
<?php
echo "<p align=CMS_ALIGN[1]>";
echo "\nDer Absatz hier wurde mit der Ausrichtungsauswahl formatiert.\n";
echo "</p>";
echo "CMS_ALIGNEDIT[1]";
?>
<!-- Testmodul ende-->
Code: Alles auswählen
/**
* CMS_ALIGNEDIT
*/
if ($edit) {
$select_values = array("left" => "linksbündig",
"center" => "zentriert",
"right" => "rechtsbündig",
"justify" => "Blocksatz");
if ($_REQUEST["type"] == "CMS_ALIGN" && $_REQUEST["typenr"] == $val) {
$SAvalue = $_REQUEST["SAvalue"];
if (in_array ($SAvalue, array_keys ($select_values))) {
consaveContentEntry($idartlang, "CMS_ALIGN", $val, $SAvalue);
conGenerateCodeForArtInAllCategories($idart);
header( "location:".$sess->url($cfgClient[$client]["path"]["htmlpath"]."front_content.php?area=$tmp_area&idart=$idart&idcat=$idcat&changeview=edit"));
}
}
}
$tmp = $a_content["CMS_ALIGN"][$val];
if ($edit) {
$editselect = '
<FORM name="SAForm_'.$val.'" method="post" action="'.$sess->url("front_content.php?idcat=$idcat&idart=$idart&idartlang=$idartlang&type=CMS_ALIGN&typenr=$val").'">
<SELECT name="SAvalue">';
foreach ($select_values as $skey => $svalue) {
$editselect .= '
<OPTION value="'.$skey.'"'.($skey == $tmp ? ' selected="selected"' : '').'>'.$svalue.'</OPTION>';
}
$editselect .= '
</SELECT>
<INPUT type="image" name="submit" value="editselect" src="'.$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"].'but_speichern.gif" border="0">
</FORM>';
$editselect = addslashes($editselect);
$editselect = addslashes($editselect);
$tmp = $editselect;
}
unset ($select_values);
?>
Dabei ist die Fehlerzeile irgendein Kommentar oder Text wo gar kein Fehler sein kann. Der Fehler verschwindet wenn ich consaveContentEntry rausnehme aber dann wird nichts gespeichert.[14-Mar-2005 23:53:11] PHP Parse error: parse error in E:\Projekte\WebSeiten\LocalWeb\contenido\contenido\includes\include.con_editcontent.php(570) : eval()'d code on line 246
Code: Alles auswählen
<?php
Code: Alles auswählen
?>
Code: Alles auswählen
<?php
/******************************************
* File : include.CMS_SELECT.php
* Project : Contenido
* Descr : Include file for editiing
* content of type CMS_SELECT
******************************************/
$select_id = $_REQUEST["select_id"];
$select_value = $_REQUEST["select_value"];
// Note: there are two selection id: $select_id and $cms_id in the script.
// $select_id is the id of the selection a user want to save, this id is sent
// to contenido by browser. $cms_id is the id used to build the form with the
// select box on it. There are several such boxies and if the user want to save
// one of them only this selection must be saved.
/**
* void selBuildSelectBox(int select_id, array select_values)
*
* Builds a select box to make the desired selection.
*
* select_id is the id of the selection to set, i.e. 15 if the selection is
* to save in the content variable CMS_SELECT[15].
*
* select_values is an array with selection values and names given as pairs
* value => name, i.e. if it is an array ('left' => 'Left', 'right' => 'Right'),
* the select box ist build with names 'Left' and 'Right' shown and values
* 'left', 'right' saved, the HTML code will be in that case:
* <SELECT>
* <OPTION value="left">Left</OPTION>
* <OPTION value="right">Right</OPTION>
* </SELECT>
*/
function selBuildSelectBox($cms_id, $select_values){
### echo "selBuildSelectBox($cms_id, $select_values) <br>\n";
global $idart, $idcat, $lang, $idartlang, $sess, $edit, $cfg;
if ($edit) {
$select = selReadSelectValue($cms_id);
$result = '
<FORM name="SELECTEDIT_'.$cms_id.'" id="SELECTEDIT_'.$cms_id.'" method="post" action="'.$sess->url("front_content.php?idcat=$idcat&idart=$idart&idartlang=$idartlang&select_id=$cms_id").'">
<SELECT name="select_value">';
foreach ($select_values as $skey => $svalue) {
$result .= '
<OPTION value="'.$skey.'"'.($skey == $select ? ' selected="selected"' : '').'>'.$svalue.'</OPTION>';
}
$result .= '
</SELECT>
<INPUT type="image" name="submit" value="editselect" src="'.$cfg["path"]["contenido_fullhtml"].$cfg["path"]["images"].'but_speichern.gif" border="0">
</FORM>';
}
return ($result);
} // end of function //
/**
* void selWriteSelectValue(int select_id, string select_value)
*
* If possible saves the selection into the database
*
* select_id is the id of the selection to set, i.e. 15 if the selection is
* to save in the content variable CMS_SELECT[15].
*
* select_value is the value to save.
*
*/
function selWriteSelectValue($cms_id, $select_value){
### echo "selWriteSelectValue($cms_id, $select_value) <br>\n";
global $cfg, $edit, $auth, $idart, $lang, $idartlang, $select_id;
if ( !$edit || $cms_id != $select_id || $cms_id < 1 || $select_value == "" ) return false; //leave with return, result makes no sense.
$db = new DB_Contenido;
$select_value = urlencode ($select_value);
// determine the article id
if ($idartlang == 0) {
$db->query("SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '$idart' AND idlang = '$lang'");
$db->next_record();
$idartlang = $db->f("idartlang");
}
// determine the id of the type CMS_SELECT
$db->query("SELECT idtype FROM ".$cfg["tab"]["type"]." WHERE type = 'CMS_SELECT'");
$db->next_record();
$idtype = $db->f("idtype");
// author and update data
$author = $auth->auth["uname"];
$date = date("Y-m-d H:i:s");
// insert or replace the entry?
$db->query("SELECT idcontent
FROM ".$cfg["tab"]["content"]."
WHERE idartlang = '$idartlang' AND idtype = '$idtype' AND typeid = '$cms_id'");
if ($db->next_record()) {
$idcontent = $db->f("idcontent");
$db->query("UPDATE ".$cfg["tab"]["content"]."
SET value = '$select_value',
lastmodified = '$date'
WHERE idcontent = '$idcontent'");
} else {
$idcontent = $db->nextid($cfg["tab"]["content"]);
$db->query("INSERT INTO ".$cfg["tab"]["content"]."
SET idcontent = '$idcontent',
idartlang = '$idartlang',
idtype = '$idtype',
typeid = '$cms_id',
value = '$select_value',
version = '',
author = '$author',
created = '$date',
lastmodified = '$date'");
}
// if two or more users wrote at the same time, more than one entry may
// be set - very bad - remove all entries except the last one.
$db->query("SELECT max(idcontent) AS maxid
FROM ".$cfg["tab"]["content"]."
WHERE idartlang = '$idartlang' AND idtype = '$idtype' AND typeid = '$cms_id'");
$db->next_record();
$maxid = $db->f("idtype");
$db->query("DELETE FROM ".$cfg["tab"]["content"]."
WHERE idcontent < '$maxid' AND
idartlang = '$idartlang' AND idtype = '$idtype' AND typeid = '$cms_id'");
// actualise the code
conGenerateCodeForArtInAllCategories($idart);
} // end of function //
/**
* string selReadSelectValue(int select_id)
*
* reads the actual selection value for the actual article from the database
* does not use the $a_content array to allow dynamic changes on the value.
*
* select_id is the id of the set selection, t.m. 15 if the selection is
* saved in the content variable CMS_SELECT[15].
*
*/
function selReadSelectValue($cms_id){
### echo "selReadSelectValue($cms_id) -> ";
global $cfg, $idart, $lang, $idartlang;
$db = new DB_Contenido;
// determine the article id
if ($idartlang == 0) {
$db->query("SELECT idartlang FROM ".$cfg["tab"]["art_lang"]." WHERE idart = '$idart' AND idlang = '$lang'");
$db->next_record();
$idartlang = $db->f("idartlang");
}
// determine the id of the type CMS_SELECT
$db->query("SELECT idtype FROM ".$cfg["tab"]["type"]." WHERE type = 'CMS_SELECT'");
$db->next_record();
$idtype = $db->f("idtype");
// reads the value
$db->query("SELECT value
FROM ".$cfg["tab"]["content"]."
WHERE idartlang = '$idartlang' AND idtype = '$idtype' AND typeid = '$cms_id'");
$db->next_record();
$result = $db->f("value");
$result = urldecode ($result);
### echo "$result<br>\n\n";
return ($result);
}
?>
Code: Alles auswählen
/**
* CMS_SELECT
*/
cInclude("includes", "include.CMS_SELECT.php");
$tmp = ( $edit ? selReadSelectValue($val)
: urldecode ($a_content['CMS_SELECT'][$val]) );
$tmp = addslashes($tmp);
$tmp = addslashes($tmp);
Code: Alles auswählen
/**
* CMS_SELECTHALIGN
*/
cInclude("includes", "include.CMS_SELECT.php");
selWriteSelectValue($val, $select_value);
$tmp = selBuildSelectBox($val, array("left" => "linksbündig",
"center" => "zentriert",
"right" => "rechtsbündig",
"justify" => "Blocksatz"));
$tmp = addslashes($tmp);
$tmp = addslashes($tmp);
Code: Alles auswählen
/**
* CMS_SELECTFONTCOLOR
*/
cInclude("includes", "include.CMS_SELECT.php");
selWriteSelectValue($val, $select_value);
$tmp = selBuildSelectBox($val, array("black" => "Schwarz",
"white" => "Weiß",
"green" => "Grün",
"blue" => "Meine Lieblingsfarbe",
"yellow" => "Gelb"));
$tmp = addslashes($tmp);
$tmp = addslashes($tmp);
Code: Alles auswählen
<!-- Testmodul OUTPUT -->
<?php
echo "CMS_SELECTHALIGN[1]";
echo "CMS_SELECTFONTCOLOR[2]";
echo "<p align='CMS_SELECT[1]'><font color='CMS_SELECT[2]'>";
echo "\nDieser Absatz wurde mit der Ausrichtungsauswahl 'CMS_SELECT[1]' und
in der Farbe 'CMS_SELECT[2]' formatiert.\n";
echo "</font></p>";
?>
<!-- Testmodul ende-->
Code: Alles auswählen
selReadSelectValue(1) -> center<br>
selReadSelectValue(2) -> blue<br>
selReadSelectValue(1) -> center<br>
selReadSelectValue(2) -> blue<br>
selWriteSelectValue(1, justify) <br>
selBuildSelectBox(1, Array) <br>
selReadSelectValue(1) -> justify<br>
selWriteSelectValue(2, justify) <br>
selBuildSelectBox(2, Array) <br>
selReadSelectValue(2) -> blue<br>
Code: Alles auswählen
<!-- Testmodul OUTPUT -->
<FORM name="SELECTEDIT_1" id="SELECTEDIT_1" method="post" action="front_content.php?idcat=2&idart=22&idartlang=42&select_id=1&contenido=2d52d1908b9f680d15386b6bd0af6d34">
<SELECT name="select_value">
<OPTION value="left">linksbündig</OPTION>
<OPTION value="center">zentriert</OPTION>
<OPTION value="right">rechtsbündig</OPTION>
<OPTION value="justify" selected="selected">Blocksatz</OPTION>
</SELECT>
<INPUT type="image" name="submit" value="editselect" src="http://localhost/contenido/contenido/images/but_speichern.gif" border="0">
</FORM>
<FORM name="SELECTEDIT_2" id="SELECTEDIT_2" method="post" action="front_content.php?idcat=2&idart=22&idartlang=42&select_id=2&contenido=2d52d1908b9f680d15386b6bd0af6d34">
<SELECT name="select_value">
<OPTION value="black">Schwarz</OPTION>
<OPTION value="white">Weiß</OPTION>
<OPTION value="green">Grün</OPTION>
<OPTION value="blue" selected="selected">Meine Lieblingsfarbe</OPTION>
<OPTION value="yellow">Gelb</OPTION>
</SELECT>
<INPUT type="image" name="submit" value="editselect" src="http://localhost/contenido/contenido/images/but_speichern.gif" border="0">
</FORM>
<p align='center'><font color='blue'>
Dieser Absatz wurde mit der Ausrichtungsauswahl 'center' und
in der Farbe 'blue' formatiert.
</font></p>
<!-- Testmodul ende-->