From d6e60b68ba310f4c27d93131f29fe3f89935a235 Mon Sep 17 00:00:00 2001 From: Christian Steinle Date: Wed, 28 Sep 2016 13:31:39 +0000 Subject: [PATCH] Anpassung an neue Editoren und Verbesserungen im Handling der Bilder im FileSystem --- .config/config_svjf.php | 2 +- .functions/fnc_webservices.php | 2 +- administrator/webservices/remote_data.php | 42 ++++++++++++++++++++--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.config/config_svjf.php b/.config/config_svjf.php index ab699bc..20cb691 100644 --- a/.config/config_svjf.php +++ b/.config/config_svjf.php @@ -12,7 +12,7 @@ if (ENVIRONMENT === 'local') elseif (ENVIRONMENT === 'production') { $svjf['editorUrl'] = $vC['portal']['arrHost']['scheme'] . '://rist-editors.ri-st.de/'; - $svjf['editorVersion'] = '1.0.1'; + $svjf['editorVersion'] = '1.0.2'; } $svjf['webserviceUrl'] = $vC['portal']['hostUrl'] . '/webservices/remote_data.php'; $svjf['grid'] = 24; diff --git a/.functions/fnc_webservices.php b/.functions/fnc_webservices.php index 669275b..dab2023 100644 --- a/.functions/fnc_webservices.php +++ b/.functions/fnc_webservices.php @@ -49,7 +49,7 @@ function fnc_buildUniqueFileName($prefix, $navId, $fileName, $fileExt) $return = str_replace($search, $replace, mb_strtolower($fileName, mb_detect_encoding($fileName))); $return = str_replace($ent, '', $return); - $result = glob(PATH_MED . $prefix . '/' . $navId . '/' . $return . '*_orig.' . $fileExt); + $result = glob(WEBSERVICE_MED . $prefix . '/' . $navId . '/' . $return . '*_orig.' . $fileExt); $count = count($result); $return = ($count > 0) ? $return . '_' . $count diff --git a/administrator/webservices/remote_data.php b/administrator/webservices/remote_data.php index f504db7..823f096 100644 --- a/administrator/webservices/remote_data.php +++ b/administrator/webservices/remote_data.php @@ -18,7 +18,7 @@ $dataSet = explode('_', $_POST['dataSet']); $table = (is_numeric(end($dataSet)) || end($dataSet) === '') ? implode('_', explode('_', $_POST['dataSet'], -1)) : $_POST['dataSet']; -$table = ($table === 'keyvisual') +$table = ($table === 'keyvisual' || $table === 'image') ? 'content_image' : $table; if (strpos($table, 'navi_') !== false) @@ -230,7 +230,16 @@ else if ($_POST['request'] === 'updateData') { if (isset ($_POST['formAction']) && $_POST['formAction'] === 'updateSort') { - $db->query('UPDATE ' . $_POST['prefix'] . '_' . TBL_NAVI . ' SET ' . $_POST['prefix'] . '_keyvisual = ' . $id . ' WHERE ' . $_POST['prefix'] . '_navId = ' . $_POST['navId'] . ' LIMIT 1;'); + if (strpos($_POST['dataSet'], 'keyvisual_') !== false) + { + $db->query('UPDATE ' . $_POST['prefix'] . '_' . TBL_NAVI . ' SET ' . $_POST['prefix'] . '_keyvisual = ' . $id . ' WHERE ' . $_POST['prefix'] . '_navId = ' . $_POST['navId'] . ' LIMIT 1;'); + } + elseif (strpos($_POST['dataSet'], 'content_image') !== false) + { + /** + * TODO: update content_textimage Element! + */ + } } else { @@ -631,7 +640,7 @@ else if ($_POST['request'] === 'insertData') elseif (isset ($_POST['formAction']) && $_POST['formAction'] === 'appendContent') { /** - * TODO: Eventuell unnötig + * TODO: Ist das nötig? */ $newId = $table . '_' . $db->insert_id; $mainSet = explode('_', $_POST['mainContent']); @@ -674,18 +683,41 @@ else if ($_POST['request'] === 'insertData') else if ($_POST['request'] === 'deleteData') { $error = false; + if ($table === 'content_image') + { + $imageData = $db->query('SELECT * FROM ' . $_POST['prefix'] . '_' . $table . ' WHERE id = ' . $id . ';'); + $image = $imageData->fetch_assoc(); + $file_path = WEBSERVICE_MED . $_POST['prefix'] . '/' . $_POST['navId'] . '/' . $image['imgName']; + + /* Alte Bilddaten löschen */ + unlink($file_path . '.' . $image['imgExtension']); + unlink($file_path . '_orig.' . $image['imgExtension']); + unlink($file_path . '_thumb.' . $image['imgExtension']); + + $contentData = $db->query('SELECT * FROM ' . $_POST['prefix'] . '_' . $table . ' WHERE id = "' . $_POST['firstImage'] . '";'); + $content = $contentData->fetch_assoc(); + $sliderContents = explode(';', $content['sliderContent']); + $sliderKey = array_keys($sliderContents, $id); + + if (!empty($sliderKey)) + { + unset($sliderContents[$sliderKey[0]]); + $db->query('UPDATE ' . $_POST['prefix'] . '_' . $table . ' SET sliderContent = "' . implode(';', $sliderContents) . '" WHERE id = "' . $content['id'] . '" LIMIT 1;'); + } + } + $result = ($table === 'content') ? $db->query('DELETE FROM ' . $_POST['prefix'] . '_' . $table . ' WHERE siteId = "' . $id . '" LIMIT 1;') : $db->query('DELETE FROM ' . $_POST['prefix'] . '_' . $table . ' WHERE id = "' . $id . '" LIMIT 1;'); - if ($result && strpos($table, 'content_') !== false) + if ($result && $table !== 'content_image') { $content_part = str_replace('content_', '', $_POST['dataSet']); $content_data = $db->query('SELECT * FROM ' . $_POST['prefix'] . '_' . TBL_CONTENT . ' WHERE siteId = "' . $_POST['navId'] . '";'); $content = $content_data->fetch_assoc(); $siteContents = explode(';', $content['siteContents']); - $content_key = array_keys($siteContents, $content_part); + $content_key = array_keys($siteContents, $id); if (!empty($content_key)) {