src/snac/client/webui/WebUIExecutor.php
/**
     * Display View Page
     *
     * Loads the view page for a given constellation input into the display.
     *
     * @param string[] $input Post/Get inputs from the webui
     * @param \snac\client\webui\display\Display $display The display object for page creation
     */
Display View Page
Loads the view page for a given constellation input into the display.


Display View Page Loads the view page for a given constellation input into the display .
public function displayViewPage(&$input, &$display) {
        $message = null;
            $serverResponse = $this->getConstellation($input, $display, false);
        if (isset($serverResponse["constellation"])) {
            if (isset($serverResponse["constellation"]["dataType"])) {
                $constellation = $serverResponse["constellation"];
                $editingUser = null;
                $holdings = array();
                 {
                    $display->setTemplate("view_page");
                    $this->logger->addDebug("Getting Holding institution information from the resource relations");
                    $c = new \snac\data\Constellation($constellation);
                    foreach ($c->getResourceRelations() as $resourceRel) {
                        if ($resourceRel->getResource() !== null && $resourceRel->getResource()->getRepository() != null) {
                            $repo = $resourceRel->getResource()->getRepository();
                            $holdings[$repo->getID()] = array(
                                "id" => $repo->getID(),
                                "name" => $repo->getPreferredNameEntry()->getOriginal()
                            );
                            foreach ($repo->getPlaces() as $place) {
                                if ($place->getGeoTerm() != null) {
                                    $holdings[$repo->getID()]["latitude"] = $place->getGeoTerm()->getLatitude();
                                    $holdings[$repo->getID()]["longitude"] = $place->getGeoTerm()->getLongitude();
                                }
                            }
                        }
                    }
                    usort($holdings, function($a, $b) {
                        return $a["name"] <=> $b["name"];
                    });
                    if (isset($serverResponse["editing_user"]))
                        $editingUser = $serverResponse["editing_user"];
                    if (\snac\Config::$DEBUG_MODE == true) {
                        $display->addDebugData("constellationSource", json_encode($serverResponse["constellation"], JSON_PRETTY_PRINT));
                        $display->addDebugData("serverResponse", json_encode($serverResponse, JSON_PRETTY_PRINT));
                    }
                 }
                 Check for a redirect
                if ($serverResponse["result"] == "success-notice") {
                    $message = $serverResponse["message"];
                }
                $this->logger->addDebug("Setting constellation data into the page template");
                $display->setData(array_merge(
                    $constellation,
                    array(
                        "preview"=> (isset($input["preview"])) ? true : false,
                        "maybeSameCount"=> (isset($serverResponse["maybesame_count"])) ? $serverResponse["maybesame_count"] : 0,
                        "message" => $message,
                        "holdings" => $holdings,
                        "editingUser" => $editingUser)
                    )
                );
            } else {
                 We have multiple constellations, so redirect to split page
                $this->displaySplitChoicePage($serverResponse, $display);
            }
        } else {
            $this->logger->addDebug("Error page being drawn");
            $this->drawErrorPage($serverResponse, $display);
        }
    }
public function displayViewPage ( & $ input , & $ display ) { $ message = null ; $ serverResponse = $ this -> getConstellation ( $ input , $ display , false ) ; if ( isset ( $ serverResponse [ " constellation " ] ) ) { if ( isset ( $ serverResponse [ " constellation " ] [ " dataType " ] ) ) { $ constellation = $ serverResponse [ " constellation " ] ; $ editingUser = null ; $ holdings = array ( ) ; $ display -> setTemplate ( " view_page " ) ; $ this -> logger -> addDebug ( " Getting Holding institution information from the resource relations " ) ; $ c = new \ snac \ data \ Constellation ( $ constellation ) ; foreach ( $ c -> getResourceRelations ( ) as $ resourceRel ) { if ( $ resourceRel -> getResource ( ) !== null && $ resourceRel -> getResource ( ) -> getRepository ( ) != null ) { $ repo = $ resourceRel -> getResource ( ) -> getRepository ( ) ; $ holdings [ $ repo -> getID ( ) ] = array ( " id " => $ repo -> getID ( ) , " name " => $ repo -> getPreferredNameEntry ( ) -> getOriginal ( ) ) ; foreach ( $ repo -> getPlaces ( ) as $ place ) { if ( $ place -> getGeoTerm ( ) != null ) { $ holdings [ $ repo -> getID ( ) ] [ " latitude " ] = $ place -> getGeoTerm ( ) -> getLatitude ( ) ; $ holdings [ $ repo -> getID ( ) ] [ " longitude " ] = $ place -> getGeoTerm ( ) -> getLongitude ( ) ; } } } } usort ( $ holdings , function ( $ a , $ b ) { return $ a [ " name " ] <=> $ b [ " name " ] ; } ) ; if ( isset ( $ serverResponse [ " editing_user " ] ) ) $ editingUser = $ serverResponse [ " editing_user " ] ; if ( \ snac \ Config :: $ DEBUG_MODE == true ) { $ display -> addDebugData ( " constellationSource " , json_encode ( $ serverResponse [ " constellation " ] , JSON_PRETTY_PRINT ) ) ; $ display -> addDebugData ( " serverResponse " , json_encode ( $ serverResponse , JSON_PRETTY_PRINT ) ) ; } if ( $ serverResponse [ " result " ] == " success-notice " ) { $ message = $ serverResponse [ " message " ] ; } $ this -> logger -> addDebug ( " Setting constellation data into the page template " ) ; $ display -> setData ( array_merge ( $ constellation , array ( " preview " => ( isset ( $ input [ " preview " ] ) ) ? true : false , " maybeSameCount " => ( isset ( $ serverResponse [ " maybesame_count " ] ) ) ? $ serverResponse [ " maybesame_count " ] : 0 , " message " => $ message , " holdings " => $ holdings , " editingUser " => $ editingUser ) ) ) ; } else { $ this -> displaySplitChoicePage ( $ serverResponse , $ display ) ; } } else { $ this -> logger -> addDebug ( " Error page being drawn " ) ; $ this -> drawErrorPage ( $ serverResponse , $ display ) ; } }
Display View Page
 Loads the view page for a given constellation input into the display.
Display View Page Loads the view page for a given constellation input into the display .
// if (isset($input["part"]) && $input["part"] == "relations") // else //     $serverResponse = $this->getConstellation($input, $display, "summary"); // We have only ONE constellation, so display // if (isset($input["part"]) && $input["part"] == "relations") { // Sort the holding institutions alphabetically // } else { //     $display->setTemplate("view_page"); // // } // Check for a redirect // We have multiple constellations, so redirect to split page