function deleteScssDir($catName) { $catName = '../../scss/' . $catName; if (is_dir($catName)) { $objects = scandir($catName); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($catName . "/" . $object) == "dir") { deleteCompDir($catName . "/" . $object); } else { unlink($catName . "/" . $object); } } } reset($objects); rmdir($catName); } /*if (is_dir('../../scss/'.$catName)) { $objects = scandir('../../scss/'.$catName); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($catName."/".$object) == "dir") deleteScssDir('../../scss/'.$catName."/".$object); else unlink('../../scss/'.$catName."/".$object); } } reset($objects); rmdir('../../scss/'.$catName); } */ }
function deleteScssDir($catName) { $config = getConfig('../..'); $stylesDir = $config[0]['styles_directory']; $catName = '../../' . $stylesDir . '/' . $catName; if (is_dir($catName)) { $objects = scandir($catName); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($catName . "/" . $object) == "dir") { deleteCompDir($catName . "/" . $object); } else { unlink($catName . "/" . $object); } } } reset($objects); rmdir($catName); } }
/*$config = getConfig('../..'); $jsDir = $config[0]['js_directory']; $jsExt = $config[0]['js_extension'];*/ $settingsdb = $settingsdb->select(array()); $jsDir = $settingsdb[0]['js_directory']; $jsExt = $settingsdb[0]['js_extension']; $compDir = $settingsdb[0]['component_directory']; $compExt = $settingsdb[0]['component_extension']; $errors = array(); $data = array(); if ($catName !== $thisCat) { $errors['different'] = 'You did not spell <span class="u_textUnderline">' . $thisCat . ' </span>correctly.'; } if ($_POST['catName'] == "") { $errors['name'] = 'Input is required.'; } if (!empty($errors)) { $data['success'] = false; $data['errors'] = $errors; } else { deleteCatJsFile($jsDir, $jsExt, $compDir, $thisCat); deleteCompDir($catName); deleteScssDir($catName); deleteCatStylesImportString($catName); deleteDbRowByVal($compdb, $key, $catName); deleteDbRowByVal($catdb, $key, $catName); $data['success'] = true; $data['message'] = 'Success!'; } echo json_encode($data);
$compFilePath = '../../components/' . $dirName . ''; $scssFilePath = '../../' . $scssDir . '/' . $dirName . ''; if (!file_exists($compFilePath) && !file_exists($scssFilePath) && $dirName != "") { $errors['exists'] = 'There is not a category named ' . $dirName . '.'; } elseif ($_POST['dirName'] == "") { $errors['name'] = 'Input is required.'; } // return a response =========================================================== // if there are any errors in our errors array, return a success boolean of false if (!empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; } else { // DO ALL YOUR FORM PROCESSING HERE deleteAtomicNavIncludeString($dirName); deleteCatPageFile($dirName); deleteAtomicCatDir($dirName); deleteCompDir($dirName); deleteCatScssImportString($dirName); deleteScssDir($dirName); // show a message of success and provide a true success variable $data['success'] = true; $data['message'] = 'Success!'; } // return all our data to an AJAX call echo json_encode($data); ?>