/**
  * Show the copyedited file upload form (to add a copyedited response to a file)
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function addCopyeditedFile($args, &$request)
 {
     import('classes.monograph.MonographFile');
     $fileStage = MONOGRAPH_FILE_COPYEDIT;
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('monographId', $request->getUserVar('monographId'));
     $templateMgr->assign('fileStage', $fileStage);
     $templateMgr->assign('gridId', $this->getId());
     return fetchJson('controllers/grid/files/form/fileUploadForm.tpl');
 }
Example #2
0
function syno_repo($github_repos, $github_token, $modes)
{
    $result = array();
    foreach ($github_repos as $repoinfo) {
        $reponame = $repoinfo["user"] . '/' . $repoinfo["repo"];
        $branch = $repoinfo["branch"];
        $repo = fetchJson("https://api.github.com/repos/{$reponame}", $github_token);
        if (empty($repo["contents_url"])) {
            continue;
        }
        $info_github = fetchJson(getGithubPath($repo["contents_url"] . "?ref={$branch}", "INFO"), $github_token);
        $info = parse_ini_string(get_data($info_github["download_url"], $github_token));
        $package = preg_replace("/[^a-z0-9\\.\\-\\_]/", '', strtolower($info["package"]));
        $package_dir = "./spks/{$package}/{$branch}";
        $release_name = $package . "-" . $info['version'] . ".spk";
        if (!is_dir($package_dir)) {
            mkdir($package_dir);
            chmod($package_dir, $modes["dir"]);
        }
        // check if there is no fitting spk or an older spk
        if (!is_file("{$package_dir}/{$release_name}")) {
            $oldSPKs = glob("{$package_dir}/*.spk");
            if ($oldSPKs !== false && count($oldSPKs) > 0) {
                // remove old spks
                foreach ($oldSPKs as $filename) {
                    @unlink($filename);
                }
            }
            // pull files from github
            if (download_file(getGithubPath($repo["archive_url"], array("tarball", "/{$branch}")), "{$package_dir}/{$package}.tar", $github_token)) {
                // extract the downloaded package
                extractSource("{$package_dir}/{$package}.tar", "{$package_dir}", $modes);
                unlink("{$package_dir}/{$package}.tar");
                // create new spk
                packSPK($package_dir, $release_name);
            }
        }
        array_push($result, getSPKInfo($package, $info, $branch));
    }
    echo json_encode($result);
}