src/snac/client/webui/WebUIExecutor.php
/**
     * Handle download tasks
     *
     * This method handles the downloading of content in any type. Download tasks include serializing a
     * constellation as EAC-CPF XML, and downloading the XML (a string) as a file.
     *
     * @param string[] $input Post/Get inputs from the webui
     * @param \snac\client\webui\display\Display $display The display object for page creation
     * @param string[] $headers Response headers for the return
     * @return string The response to the client (The content of the file)
     */
Handle download tasks
This method handles the downloading of content in any type. Download tasks include serializing a
constellation as EAC-CPF XML, and downloading the XML (a string) as a file.


Handle download tasks This method handles the downloading of content in any type . Download tasks include serializing a constellation as EAC - CPF XML and downloading the XML ( a string ) as a file .
public function handleDownload(&$input, &$display, &$headers) {
        if (!isset($input["type"])) {
            return $this->drawErrorPage("Content Type not specified", $display);
        }
        $query = array();
        if (isset($input["constellationid"]))
            $query["constellationid"] = $input["constellationid"];
        if (isset($input["version"]))
            $query["version"] = $input["version"];
        if (isset($input["arkid"]))
            $query["arkid"] = $input["arkid"];
        $query["type"] = $input["type"];
        $query["command"] = "download_constellation";
        $this->logger->addDebug("Sending query to the server", $query);
        $serverResponse = $this->connect->query($query);
        $this->logger->addDebug("Received server response");
        if (isset($serverResponse["file"])) {
            array_push($headers, "Content-Type: " . $serverResponse["file"]["mime-type"]);
            array_push($headers, 'Content-Disposition: inline; filename="'.$serverResponse["file"]["filename"].'"');
            return base64_decode($serverResponse["file"]["content"]);
        } else {
            $this->drawErrorPage("Download error occurred", $display);
        }
        return null;
    }
public function handleDownload ( & $ input , & $ display , & $ headers ) { if ( ! isset ( $ input [ " type " ] ) ) { return $ this -> drawErrorPage ( " Content Type not specified " , $ display ) ; } $ query = array ( ) ; if ( isset ( $ input [ " constellationid " ] ) ) $ query [ " constellationid " ] = $ input [ " constellationid " ] ; if ( isset ( $ input [ " version " ] ) ) $ query [ " version " ] = $ input [ " version " ] ; if ( isset ( $ input [ " arkid " ] ) ) $ query [ " arkid " ] = $ input [ " arkid " ] ; $ query [ " type " ] = $ input [ " type " ] ; $ query [ " command " ] = " download_constellation " ; $ this -> logger -> addDebug ( " Sending query to the server " , $ query ) ; $ serverResponse = $ this -> connect -> query ( $ query ) ; $ this -> logger -> addDebug ( " Received server response " ) ; if ( isset ( $ serverResponse [ " file " ] ) ) { array_push ( $ headers , " Content-Type:  " . $ serverResponse [ " file " ] [ " mime-type " ] ) ; array_push ( $ headers , 'Content-Disposition: inline; filename="' . $ serverResponse [ " file " ] [ " filename " ] . '"' ) ; return base64_decode ( $ serverResponse [ " file " ] [ " content " ] ) ; } else { $ this -> drawErrorPage ( " Download error occurred " , $ display ) ; } return null ; }
Handle download tasks
 This method handles the downloading of content in any type.
Handle download tasks This method handles the downloading of content in any type .
/*
            Ask server to "download_constellation" with the type parameter and constellationid, arkid, etc.

            $input["type"]

            Server will give the following response:

            $response["file"] = array();
            $response["file"]["mime-type"] = "text/json";
            $response["file"]["filename"] = $this->arkToFilename($constellation->getArkID()).".json";
            $response["file"]["content"] = base64_encode(json_encode($constellation, JSON_PRETTY_PRINT));
        */