示例#1
0
function service_search_db($args, $dupes)
{
    $pdf_ids = array();
    if ($args) {
        foreach ($args as $tag) {
            if (!get_tag_info($tag)) {
                err_bad_input_data('tag', $tag, "doesn't exist");
            }
            $pdf_ids = array_unique(array_merge($pdf_ids, find_pdfs_with_tag($tag)));
        }
    } else {
        if ($dupes) {
            $pdf_ids = find_pdfs_with_dupes();
        } else {
            if (is_array($args)) {
                $pdf_ids = find_pdfs_with_no_tag();
            } else {
                $pdf_ids = find_pdfs_all();
            }
        }
    }
    $pdfs = array();
    if ($pdf_ids) {
        foreach ($pdf_ids as $pdf_id) {
            $pdfs[] = prepare_pdf_record($pdf_id);
        }
    }
    echo json_encode(array('data' => $pdfs));
}
示例#2
0
            $path = null;
            $dupe_paths = array();
            foreach ($dupes as $dupe_id) {
                $dupe_info = get_pdf_info($dupe_id);
                if ($path == null) {
                    $path = $dupe_info['path'];
                } else {
                    $dupe_paths[] = $dupe_info['path'];
                }
            }
            echo "merging metadata: ";
            print_r($dupes);
            $new_id = merge_pdf_metadata($dupes, $path);
            if ($new_id) {
                echo "new pdf id: {$new_id}\n";
                foreach ($dupe_paths as $dupe_path) {
                    delete_pdf_file($dupe_path);
                }
            } else {
                echo "merge failed\n";
            }
        }
    }
}
echo "Total records: " . count(find_pdfs_all()) . "\n";
echo "orphans: \n";
foreach ($orphans as $pdf_id) {
    print_r(get_pdf_info($pdf_id));
    echo "deleting path info (making this pdf an orphan)...";
    orphan_pdf($pdf_id);
}