$new_file = file_get_contents($new_parse_file); $design = $GLOBALS['SQ_SYSTEM']->am->getAsset($id); $design_edit_fns = $design->getEditFns(); $type_code = ucwords(str_replace('_', ' ', $design->type())); // Update design parse file for ees_login_design, there is some css changes $parse_file = $design->data_path . '/parse.txt'; $ext_file = file_get_contents($parse_file); $parse_file_md5 = md5(file_get_contents($parse_file)); if ($parse_file_md5 != $source_parse_file_md5) { echo 'Parse file in ' . $type_code . ' was modified. Skipping.' . "\n"; } else { if (!is_file($parse_file) || !is_file($new_parse_file)) { trigger_error('parse file is not available'); } else { // update the parse file if (!_updateFile($new_parse_file, 'parse.txt', $design->data_path, $design->data_path_suffix)) { trigger_error('failed to update parse file ' . $new_parse_file); exit; } $design_edit_fns->parseAndProcessFile($design); $design->generateDesignFile(); echo 'Parse file in ' . $type_code . ' Successfully updated...' . "\n"; } } } echo "\n" . 'All desings updated successfully' . "\n"; $GLOBALS['SQ_SYSTEM']->restoreRunLevel(); $GLOBALS['SQ_SYSTEM']->am->forgetAsset($design_folder->id, TRUE); /** * _updateFile * Update the target file by removing it first and then replace with a new file, update file versioning of it
} } if (empty($existing_fileid)) { trigger_error('Can not find original logo image'); exit; } // we already have a design file with the same name, so just upload over the top of it $file = $GLOBALS['SQ_SYSTEM']->am->getAsset($existing_fileid); // check MD5 hash, make sure it is the file we want to update $file_info = $file->getExistingFile(); if (md5_file($file_info['path']) !== $md5) { echo $file_name . ' in ' . $type_code . ' was modified. Skip...' . "\n"; continue; } // update the actual logo file if (!_updateFile($path, $file_name, $file->data_path, $file->data_path_suffix)) { trigger_error('failed to update logo ' . $file_name); exit; } echo $file_name . ' in ' . $type_code . '. Successfully updated...' . "\n"; } echo 'Done' . "\n"; $GLOBALS['SQ_SYSTEM']->restoreRunLevel(); /** * _updateFile * Update the target file by removing it first and then replace with a new file, update file versioning of it * * @return Boolean */ function _updateFile($new_file, $file_name, $data_path, $data_path_suffix) {