das sind jetzt ein paar größere änderungen die ich für ein neues projekt benötigt habe... wäre schön wenn es das in den snapshot schaffen würde...
im prinzip ist das ganze eine kleine erweiterung/vereinfachung/cleanup/bugfix für die bearbeitungsfunktionen im backend...
die bestehende funktionsweise wird nicht verändert, sondern erweitert...
einige unnötige variablen definitionen wurden entfernt bzw vereinfacht, bzw. den php funktionen angeglichen... (viel leichter beim debuggen)
alle code änderungen beziehen sich auf den snapshot 2005-08-29
Code: Alles auswählen
if( $action == 20 || $action == 10 ) {
if( $data != "" ) {
$array1 = explode("||", substr($data, 0, -2));
foreach($array1 as $value){
$array2 = explode("|", $value);
if ( $array2[2] == "!!" ){
$array2[2] = "";
} else {
$array2[2] = str_replace("%$%SPERATOR%$%", "|", $array2[2]);
}
conSaveContentEntry($array2[0], "CMS_".$array2[3], $array2[1], $array2[2]);
conGenerateCodeForArtInAllCategories($idart);
}
conGenerateCodeForArtInAllCategories($idart);
}
}
Code: Alles auswählen
if( $action == 20 || $action == 10 ) {
if( $data != "" ) {
$data = explode("||", substr($data, 0, -2));
foreach($data as $value){
$value = explode("|", $value);
if ( $value[3] == "%$%EMPTY%$%" ){
$value[3] = "";
} else {
$value[3] = str_replace("%$%SEPERATOR%$%", "|", $value[3]);
}
conSaveContentEntry($value[0], "CMS_".$value[1], $value[2], $value[3]);
//echo "conSaveContentEntry({$value[0]}, CMS_{$value[1]}, {$value[2]}, value)<br>\n";
}
// restore orginal values
$data = $_REQUEST['data'];
$value = $_REQUEST['value'];
conGenerateCodeForArtInAllCategories($idart);
}
}
verwendet werden statt dessen nur $data und $value
zusätzlich werden die orginal werte von $data und $value nach der speicherung wieder hergestellt...
der doppelte aufruf von conGenerateCodeForArtInAllCategories ist auch rausgeflogen...
die variablen reihung für conSaveContentEntry
wurde an die reihenfolge der phpfunktion angepasst...
der nächste teil bezieht sich auf eine javascript funktion in der selben datei...
Code: Alles auswählen
function setcontent(idart, act) {
if (document.all)
{
document.getElementsByTagName = function (str)
{
if (str=="*")
return document.all;
else
return document.all.tags(str);
}
}
var a = document.getElementsByTagName("*");
var str = '';
var aId = '';
var dcoElementCnt = 0;
// loop through all elements
for (var i=0; i < a.length; i++) {
aId = a[i].id;
if (aId != '' && typeof aId == 'string') {
aIdPrefix = aId.substr(0,4);
// search for the id which containes HTML
if (aIdPrefix == 'HTML') {
// check if its an 'contentEditable' Field
if (a[i].isContentEditable == true) {
// read out the content
var aContent = a[i].innerHTML;
// split the idname in data - datas 0 is the Fieldname 2 is the typeid
var data = aId.split("_");
if ( aContent == "" ) {
aContent = "!!";
} else {
// if there is an | in the text set a replacement chr because we use it later as isolator
while( aContent.search(/\|/) != -1 ) {
aContent = aContent.replace(/\|/,'%$%SPERATOR%$%');
}
}
// build the string which will be send
str += idart +'|'+ data[2] +'|'+ aContent +'|'+ data[0] +'||';
}
}
}
}
// set the string
document.forms.editcontent.data.value = str;
// set the action string
if ( act != 0 ) {
document.forms.editcontent.action = act;
}
// if there are 3 arguments, the className has to be seached
if(arguments.length > 2){
//search the class of the above element
var classname = getCellClass(arguments[2]);
if ( classname ) {
document.forms.editcontent.con_class.value = classname;
}
}
// submit the form
document.forms.editcontent.submit();
}
Code: Alles auswählen
function setcontent(idartlang, act) {
if (document.all) {
document.getElementsByTagName = function (str) {
if (str=="*")
return document.all;
else
return document.all.tags(str);
}
}
var a = document.getElementsByTagName("*");
var str = '';
var aId = '';
// loop through all elements
for (var i=0; i < a.length; i++) {
aId = a[i].id;
if (aId != '' && typeof aId == 'string') {
var aIdPrefix = aId.substr(0,4);
// search for the id which containes HTML
if (aIdPrefix == 'HTML') {
// check if its an 'contentEditable' Field
if (a[i].isContentEditable == true) {
// split the idname in data
var data = aId.split("_");
// data[0] is the fieldname * needed
// data[1] is the idtype
// data[2] is the typeid * needed
// read out the content
var aContent = prepareString(a[i].innerHTML);
// build the string which will be send
str += buildDataEntry(idartlang , data[0] , data[2] , aContent);
}
}
}
}
// set the string
document.forms.editcontent.data.value = str + document.forms.editcontent.data.value;
// set the action string
if ( act != 0 ) {
document.forms.editcontent.action = act;
}
// if there are 3 arguments, the className has to be seached
if(arguments.length > 2){
//search the class of the above element
var classname = getCellClass(arguments[2]);
if ( classname ) {
document.forms.editcontent.con_class.value = classname;
}
}
// submit the form
document.forms.editcontent.submit();
}
function prepareString(aContent) {
if ( aContent == "" ) {
aContent = "%$%EMPTY%$%";
} else {
// if there is an | in the text set a replacement chr because we use it later as isolator
while( aContent.search(/\|/) != -1 ) {
aContent = aContent.replace(/\|/,"%$%SEPERATOR%$%");
}
}
return aContent;
}
function buildDataEntry(idartlang, type, typeid, value) {
return idartlang +'|'+ type +'|'+ typeid +'|'+ value +'||';
}
function addDataEntry(idartlang, type, typeid, value) {
document.forms.editcontent.data.value = (buildDataEntry(idartlang, type, typeid, prepareString(value) ) );
setcontent(idartlang,'0');
}
war der grund warum zeitweise !! aus den textfelder einfach verschwand... (falls es noch keinem aufgefallen ist)...
prepareString und buildDataEntry leiten sich natürlich von setcontent ab...
da ich diese funktionalität öfters benötige blieb mir nur eine ausgliederung übrig...
function addDataEntry ist neu... damit ist es möglich mittels eines javascript aufrufs werte in der con_content einem con_type direkt zuzuweisen... (momentan wird das nur für CMS_HTML/HEAD gemacht und es klingt jetzt komplizierter wie es ist)
zb (einfaches beispiel):
Code: Alles auswählen
<?php
echo "<a href=\"javascript:addDataEntry('$idartlang', 'LINK', '1', '');\">Clear</a>";
?>
der aufruf von setcontent(idartlang,'0'); innerhalb von addDataEntry speichert aber zusätzlich alle CMS_HTML/HEAD elemente...
noch etwas zu setcontent
die wichtigste zeile dass das ganz funktioniert ist das hier
Code: Alles auswählen
document.forms.editcontent.data.value = str + document.forms.editcontent.data.value;
tja das ist es im großen und ganzen...