$data = array();
$compName = $_POST["compName"];
$newCat = $_POST["newCat"];
$oldCat = $_POST["oldCat"];
$thisCompName = $_POST["thisCompName"];
$config = getConfig('../..');
$stylesDir = $config[0]['styles_directory'];
$stylesExt = $config[0]['styles_extension'];
$compDir = $config[0]['component_directory'];
$compExt = $config[0]['component_extension'];
$filename = '../../' . $compDir . '/' . $newCat . '/' . $thisCompName . '.' . $compExt . '';
$scssFilePath = '../../' . $stylesDir . '/' . $newCat . '/_' . $thisCompName . '.' . $stylesExt . '';
if (file_exists($filename) || file_exists($scssFilePath) && $catName != "") {
    $errors['exists'] = 'A component named ' . $thisCompName . ' already exists in the target location.';
}
if (!empty($errors)) {
    $data['success'] = false;
    $data['errors'] = $errors;
} else {
    navCatCompOrder($compdb, $compName, $newCat);
    stylesCompRootOrder($compName, $newCat);
    deleteStylesImportString($thisCompName, $oldCat);
    moveCompFile($oldCat, $thisCompName, $newCat);
    moveStyleFile($oldCat, $thisCompName, $newCat);
    editAllCompCommentStrings($oldCat, $newCat);
    editAllStyleCommentStrings($oldCat, $newCat);
    $data['success'] = true;
    $data['message'] = 'Success!';
}
// return all our data to an AJAX call
echo json_encode($data);
Exemplo n.º 2
0
$catdb = new Fllat("categories", "../../atomic-db");
$compdb = new Fllat("components", "../../atomic-db");
$catName = $_POST["catName"];
$thisCat = $_POST["thisCat"];
$key = "category";
$errors = array();
$data = array();
/*if ($catName == $thisCat){
    $errors['different'] = ' <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 {
    dbUpdateItems($catdb, $key, $thisCat, $catName);
    dbUpdateItems($compdb, $key, $thisCat, $catName);
    renameCompDir($thisCat, $catName);
    //update all comp file comment strings
    renameStyleDir($thisCat, $catName);
    renameStylesRoot($catName, $thisCat);
    //update all style file comment stings
    changeRootStylesImportString($catName, $thisCat);
    editAllCompCommentStrings($thisCat, $catName);
    editAllStyleCommentStrings($thisCat, $catName);
    $data['success'] = true;
    $data['message'] = 'Success!';
}
echo json_encode($data);