$data = rscandir($import_path);
//check if every file is presented in the manifest
foreach($data as $filepath){
- debug(preg_match('/(.*)\.xml/', substr($filepath, strlen($import_path))));
+// debug(preg_match('/(.*)\.xml/', substr($filepath, strlen($import_path))));
//validate xml via its xsd/dtds
if (preg_match('/(.*)\.xml/', substr($filepath, strlen($import_path)))){
libxml_use_internal_errors(true);
$dom = new DOMDocument();
$dom->load(realpath($filepath));
- debug(realpath($filepath), 'filepath');
+// debug(realpath($filepath), 'filepath');
if (!$dom->schemaValidate('main.xsd')){
$errors = libxml_get_errors();
- debug($errors);exit;
+// debug($errors);exit;
foreach ($errors as $error) {
//suppress warnings
if ($error->level==LIBXML_ERR_WARNING){
$all_package_base_path = implode('/', $all_package_base_path);
}
- if ($common_path != '' && substr($content_info['new_path'], strlen($common_path))) {
+ // The following condition checks if there is a common path, if so, remove it from the content base_href.
+ // This prevents the path to grow longer.
+ if ($common_path != ''
+ && ($content_info['new_path'] === $common_path
+ || substr($content_info['new_path'], strlen($common_path)))) {
$content_info['new_path'] = $package_base_name . substr($content_info['new_path'], strlen($common_path));
} else {
$content_info['new_path'] = $package_base_name . '/' . $content_info['new_path'];