I wont describe whats here, just figure it out yerself, enjoy =)
Save, edit & update languages in one time
// Mass Language Manager
function SaveAll() {
// adding
$_REQUEST['val'] = array_unique($_REQUEST['val']);
foreach ($_REQUEST['val'] as $key => $keyValue) {
if (!$keyValue OR !strlen(join('',$_REQUEST['new'][$key]))) continue;
if (!($keyValue = alnum($keyValue))) continue;
if (mb_strlen($keyValue)>25 OR $this->checkForKey($keyValue)) continue;
foreach ($_REQUEST['new'] as $i => $arrLangVal) {
foreach ($arrLangVal as $lang => $value) {
if ($value) {
$_REQUEST['new'][$i][$lang] = addslashes($value);
} else {
foreach ($arrLangVal as $l => $v) {
if ($arrLangVal[$l]) {
$_REQUEST['new'][$i][$lang] = addslashes($v);
}
}
}
}
}
$strSql = 'INSERT INTO '.$this->strTable.'
(val, '.join(',',array_keys($_REQUEST['new'][$key])).')
VALUES
(\''.$keyValue.'\', \''.join('\',\'',array_values($_REQUEST['new'][$key])).'\')';
$this->objDB->query($strSql);
}
// deleting
$delArr = array();
if (count($_REQUEST['del'])) {
foreach ($_REQUEST['del'] as $keyVal => $Y) {
if ($Y!='Y') continue;
$delArr[] = $keyVal;
$strSql = 'DELETE FROM '.$this->strTable.' WHERE val=\''.$keyVal.'\'';
$this->objDB->query($strSql);
}
}
// updating
if (!count($_REQUEST['old'])) return;
foreach ($_REQUEST['old'] as $keyValue => $arrLangVal) {
if (in_array($keyValue,$delArr) OR !strlen(join('',$_REQUEST['old'][$keyValue]))) continue;
$arrUpdateValues = array();
foreach ($arrLangVal as $lang => $value) {
if ($value) {
$arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
} else {
foreach ($arrLangVal as $lang => $value) {
if ($arrLangVal[$lang]) {
$arrUpdateValues[] = $lang.'=\''.addslashes($value).'\'';
}
}
}
}
$strSql = 'UPDATE '.$this->strTable.'
SET '.join(',',$arrUpdateValues).'
WHERE
val = \''.$keyValue.'\'';
$this->objDB->query($strSql);
}
}
Dani 4,312 The Queen of DaniWeb Administrator Featured Poster Premium Member
nav33n 472 Purple hazed! Team Colleague Featured Poster
Shanti C 106 Posting Virtuoso
anmurthy 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.