Esempio n. 1
0
 function testThrowsBadMethodCallExceptionFor()
 {
     $this->setExpectedException('BadMethodCallException');
     $this->request->expects($this->any())->method('getContentType')->willReturn('bad content type');
     $requestParser = new RequestParser($this->request);
     $requestParser->parseRequestData();
 }
 public function testParse()
 {
     $serverInfo = new ServerInfo(self::$test_data1);
     $p1 = new RequestParser($serverInfo);
     $expected = array('search', 'test', 'index.php?p1=param1&p2=param2');
     $actual = $p1->parse();
     $this->assertEquals($expected, $actual, __CLASS__ . "::" . __METHOD__ . ": line " . __LINE__);
 }
 public function testRequestParserGetsCorrectDataSet()
 {
     $requestFactory = new TestRequestFactory();
     $request = $requestFactory->MakeMockRequest();
     $requestParser = new RequestParser();
     $parsedRequest = $requestParser->Parse($request);
     $this->assertEquals("googlebot:", $parsedRequest->Trigger);
     $this->assertEquals("test", $parsedRequest->Channel);
     $this->assertEquals("googlebot: What is the air-speed velocity of an unladen swallow?", $parsedRequest->Text);
     $this->assertEquals("Steve", $parsedRequest->Username);
 }
 public function read(DOMNode $element, ParseContext $parseContext)
 {
     /*int*/
     $refID = -1;
     $element = $element->ownerDocument->documentElement;
     if ($element->hasAttribute("referenceID")) {
         $refID = $element->getAttribute("referenceID");
     }
     /*ArrayList*/
     $arrayElements = array();
     /*RequestParser*/
     $requestParser = RequestParser::GetInstance();
     for ($i = 0; $i < $element->childNodes->length; $i++) {
         $xmlNode = $element->childNodes->item($i);
         if (!$xmlNode instanceof DOMNode) {
             continue;
         }
         $arrayElements[] = $requestParser->ParseElement($xmlNode, $parseContext);
     }
     //           /* ArrayType*/ array = new ArrayType( (IAdaptingType[]) arrayElements.ToArray( typeof( IAdaptingType ) ) );
     if ($refID != -1) {
         $parseContext->addReference($arrayElements, $refID);
     }
     return $arrayElements;
 }
 /**
  * Parses the specified request source for a parameter which corresponds to the specified param key.
  * The param filter type will be utilize to determine which pre-configured regex pattern will be utilized
  * to filter the parameter.
  * @param array $requestSource The source which the parameter data will be drawn from.
  * @param String $paramKey The key which will be used to retrieve the parameter data.
  * @param int $paramFilterType The predefined filter type which will be utilized to determine which
  * regex filter will be applied to filter the parameter value. If not specified, no filtering will occur.
  * @return The retrieved and filtered parameter value, if found. Otherwise NULL.
  */
 public static function parseRequestParam(array $requestSource, $paramKey, $paramFilterType = NULL)
 {
     if ($paramFilterType == NULL) {
         if (isset($requestSource[$paramKey])) {
             return $requestSource[$paramKey];
         } else {
             return NULL;
         }
     }
     if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_INT) {
         return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[0-9]*$/');
     } else {
         if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC) {
             return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[a-zA-Z0-9]*$/');
         } else {
             if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_ALPHA_ONLY) {
                 return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[a-zA-Z]*$/');
             } else {
                 if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_ALPHA_WS_ONLY) {
                     return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[a-zA-Z\\s]*$/');
                 } else {
                     if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC_WS_ONLY) {
                         return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[a-zA-Z0-9\\s]*$/');
                     } else {
                         if ($paramFilterType == RequestParser::PARAM_FILTER_TYPE_EMAIL_ADDRESS) {
                             return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey, '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/');
                         } else {
                             return RequestParser::parseRequestParamWithRegex($requestSource, $paramKey);
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * This function performs the processing of the user request.
  * @param User $user The requesting user, only if this action requires authorization, 
  * default to NULL otherwise.
  * @throws Exception If an error was encountered while processing this request, an exception
  * will be thrown.
  * @return void
  */
 public function processRequest(User $user = NULL)
 {
     $relativeImagePath = RequestParser::parseRequestParam($_GET, AccessImageAction::RELATIVE_IMAGE_PATH_GET_PARAM);
     // if a relative image was specified as a request parameter, process the request
     if ($relativeImagePath != NULL) {
         $imagePath = $this->baseImageDir . $relativeImagePath;
         // ensure the specified path exists and is readable
         if (file_exists($imagePath) && is_readable($imagePath)) {
             // parse the directory of the requested image
             $directoryPath = dirname($imagePath);
             if (!empty($directoryPath)) {
                 // check to see if the directory requires authentication, if so verify the user is authenticated
                 if (isset($this->imageDirectoryAuthorizationMap[$directoryPath]) && $this->imageDirectoryAuthorizationMap[$directoryPath]) {
                     // if the user is null, then the requester is not authenticated
                     if ($user == NULL) {
                         $this->displayDefaultErrorImage();
                         return;
                     }
                 }
                 // at this point it is assumed the requester is allowed to view the image
                 $this->displayImage($imagePath);
                 return;
             }
         }
     }
     // otherwise display an error image
     $this->displayDefaultErrorImage();
 }
Esempio n. 7
0
 public static function processRequest()
 {
     global $logger;
     $request = $rawResponse = $response = null;
     try {
         /* Authenticate */
         $valid = self::authenticateRequest($_SERVER);
         /* Fetch POST data */
         $post = file_get_contents("php://input");
         $logger->debug("POST Data Received: " . $post);
         /* Formulate the request object */
         $request = RequestParser::parseInput($_SERVER, $_GET, $post);
         $logger->debug("REQUEST Object: " . $request->toString());
         /* Handle the request */
         $rawResponse = RequestHandler::process($request);
         $logger->debug("RESPONSE Object: " . json_encode($rawResponse));
     } catch (ApiException $e) {
         /* Generate response from Exception details */
         $logger->error("ApiException encountered!! " . $e->toString());
         $rawResponse = array('httpStatusCode' => $e->getHttpStatusCode(), 'httpStatusCodeMessage' => $e->getHttpStatusCodeMessage(), 'otherHeaders' => $e->getOtherHeaders(), 'code' => $e->getCode(), 'message' => $e->getMessage(), 'debug' => false, 'data' => null);
     }
     // Format the $rawResponse variable and output
     $format = !isset($request) ? 'json' : $request->getFormat();
     $debug = !isset($request) ? false : $request->getDebug();
     $response = ResponseHandler::respond($rawResponse, $format, $debug);
     $logger->debug("Output: " . $response);
 }
Esempio n. 8
0
 public function handleRequest()
 {
     $rawRequest = $str = fgets($this->in);
     while ($str != "\n") {
         $rawRequest .= $str = fgets($this->in);
     }
     $this->request = RequestParser::createRequest($rawRequest);
 }
 /**
  * This function performs the processing of the user request.
  * @param User $user The requesting user. If the user is not null, then by convention
  * actions will assume the user is authenticated, otherwise not.
  * @throws Exception If an error was encountered while processing this request, an exception
  * will be thrown.
  * @return void
  */
 public function processRequest(User $user = NULL)
 {
     // if for some reason we decide to require authentication for some scripts, this would be the place to put such functionality
     $requestedFileName = RequestParser::parseRequestParam($_GET, AccessJavascriptAction::JAVASCRIPT_FILE_GET_PARAM);
     // retrieve the requested javascript file from the request
     if ($requestedFileName != NULL) {
         $filePath = $this->baseJavascriptDir . $requestedFileName;
         // verify the file exists and is readable
         if (file_exists($filePath) && is_readable($filePath)) {
             // deliver the javascript file
             header('Content-type: text/javascript');
             readfile($filePath);
         }
     }
 }
 public function read(DOMNode $element, ParseContext $parseContext)
 {
     /*int*/
     $refID = -1;
     $element = $element->ownerDocument->documentElement;
     if ($element->hasAttribute("referenceID")) {
         $refID = $element->getAttribute("referenceID");
     }
     /*Hashtable*/
     $properties = array();
     /*RequestParser*/
     $xmlRequestParser = RequestParser::GetInstance();
     /*XmlNodeList*/
     $xmlNodes = $element->getElementsByTagName("Field");
     for ($i = 0; $i < $xmlNodes->childNodes->length; $i++) {
         $xmlNode = $xmlNodes->childNodes->item($i);
         /*string*/
         $fieldName = null;
         /*IAdaptingType*/
         $fieldValue = null;
         for ($j = 0; $j < $xmlNode->childNodes->length; $j++) {
             $fieldNode = $xmlNode->childNodes->item($j);
             switch ($fieldNode->nodeName) {
                 case "Name":
                     $fieldName = trim($fieldNode->textContent);
                     break;
                 case "Value":
                     $fieldValue = $xmlRequestParser->ParseElement($fieldNode->firstChild, $parseContext);
                     break;
             }
         }
         $properties[$fieldName] = $fieldValue;
     }
     /*IAdaptingType*/
     $obj = new AnonymousObject($properties);
     /*string*/
     $objectName = $element->getAttribute("objectName");
     if ($objectName != null && strlen(trim($objectName)) != 0) {
         $obj = new NamedObject($objectName, $obj);
     }
     if ($refID != -1) {
         $parseContext->addReference($obj, $refID);
     }
     return $obj;
 }
    public function processRequest(User $user = NULL)
    {
        parent::displayHeader($user, 'Image Search Results');
        // compose and execute query
        $dbConnection = DbConnectionUtil::getDbConnection();
        $queryString = 'SELECT imd.id FROM image_data imd ';
        $attribute = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_ATTRIBUTE, RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC_WS_ONLY);
        if ($attribute != NULL) {
            $queryString .= "INNER JOIN image_attribute ima ON imd.id = ima.image_data_id AND ima.attribute LIKE '%{$attribute}%' ";
        }
        $queryString .= ' WHERE 1=1 ';
        $title = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_TITLE, RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC_WS_ONLY);
        if ($title != NULL) {
            $queryString .= "AND imd.title LIKE '%{$title}%' ";
        }
        $year = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_YEAR, RequestParser::PARAM_FILTER_TYPE_INT);
        if ($year != NULL) {
            $queryString .= "AND imd.year LIKE '%{$year}%' ";
        }
        $author = RequestParser::parseRequestParam($_REQUEST, ImageSearchResultsView::POST_PARAM_AUTHOR, RequestParser::PARAM_FILTER_TYPE_ALPHA_WS_ONLY);
        if ($author != NULL) {
            $queryString .= "AND imd.author LIKE '%{$author}%' ";
        }
        //print( "<br/>queryString: $queryString<br/><br/>" );
        $preparedStatement = $dbConnection->prepare($queryString);
        $preparedStatement->execute();
        $idList = array();
        while ($resultRow = $preparedStatement->fetch(PDO::FETCH_ASSOC)) {
            $idList[] = $resultRow['id'];
        }
        $preparedStatement = NULL;
        if (count($idList) > 0) {
            $imageDataResultList = ImageData::loadImageDataListByIdSet($dbConnection, $idList);
        } else {
            $imageDataResultList = array();
        }
        ?>
	<h1>Search Results</h1>
	<br/>
	<div class="imageDetailsView">
	<?php 
        foreach ($imageDataResultList as $imageData) {
            $viewImageDetailsUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId()));
            ?>
		 <div class="searchResultItem">
		 <?php 
            $thumbnailUri = $imageData->getThumbnailUri();
            if (!empty($thumbnailUri)) {
                ?>
		       <div>
		       	<a href="<?php 
                echo $viewImageDetailsUrl;
                ?>
"><img  id="thumbnail_field" src="<?php 
                echo UrlFormatter::formatImageUrl($imageData->getThumbnailUri());
                ?>
"/></a>
			 <br/>
			 <a href="<?php 
                echo $viewImageDetailsUrl;
                ?>
">Details</a>
		       
		       </div>
		       <?php 
                $title = $imageData->getTitle();
                if ($title != null) {
                    ?>
		       		<label for="title_field">Title</label>
		      		 <span  id="title_field" class="imageDetailsField"><?php 
                    echo $title;
                    ?>
</span>
		      		 <br/>
		      		 <?php 
                }
                ?>
		       <?php 
                $author = $imageData->getAuthor();
                if ($author != null) {
                    ?>
		       		<label for="author_field">Author</label>
		      		 <span  id="author_field" class="imageDetailsField"><?php 
                    echo $author;
                    ?>
</span>
		      		 <br/>
		      		 <?php 
                }
                ?>
			<br/>
		       	
		       <?php 
            }
            ?>
		 </div>
		 <div style="clear:both"></div>
		 <?php 
        }
        ?>
	</div>
	<?php 
        parent::displayFooter();
    }
if ($paramValue != NULL) {
    printf("FAILED: expected NULL value, retrieved value: {$paramValue}\n");
    exit(-1);
}
printf("PASSED\n");
printf("testing retrieving valid alpha-numeric string...");
$requestSource['testString'] = '12323klsjdflkASj23';
$paramValue = RequestParser::parseRequestParam($requestSource, 'testString', RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC);
if ($paramValue == NULL) {
    printf("FAILED: failed to retrieve param value.\n");
    exit(-1);
}
if ($paramValue != $requestSource['testString']) {
    printf("FAILED: retrieved value did not match input value: inputValue: {$requestSource['testString']} retrievedValue: {$paramValue}\n");
    exit(-1);
}
printf("PASSED\n");
printf("testing retrieving invalid alpha-numeric string...");
$requestSource['testString'] = '12323klsjdflkASj23_+!@+@#';
$paramValue = RequestParser::parseRequestParam($requestSource, 'testString', RequestParser::PARAM_FILTER_TYPE_ALPHA_NUMERIC);
if ($paramValue != NULL) {
    printf("FAILED: expected NULL value, retrieved value: {$paramValue}\n");
    exit(-1);
}
printf("PASSED\n");
// TODO finish me
printf("testing retrieving valid email address...");
$requestSource['testEmail'] = '*****@*****.**';
//$paramValue =
// test a custom regex
// test without regex
    public function processRequest(User $user = NULL)
    {
        // attempt to parse and load the next image id
        $nextImageId = RequestParser::parseRequestParam($_REQUEST, self::GET_PARAM_NEXT_IMAGE_ID, RequestParser::PARAM_FILTER_TYPE_INT);
        // if no image was specified, redirect to the start journey view
        $startJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/StartJourneyView');
        if (!$nextImageId) {
            header("Location: {$startJourneyUrl}");
            exit;
        }
        $dbConnection = DbConnectionUtil::getDbConnection();
        $nextImageData = ImageData::loadImageDataById($dbConnection, $nextImageId);
        if (!$nextImageData) {
            header("Location: {$startJourneyUrl}");
            exit;
        }
        parent::displayHeader($user, 'Journey');
        // attempt to parse the chosen attribute, if specified add to its tally
        if (isset($_GET[self::GET_PARAM_CHOSEN_ATTRIBUTE])) {
            $chosenAttribute = $_GET[self::GET_PARAM_CHOSEN_ATTRIBUTE];
            // verify the specified chosen attribute is actually an attribute of the chosen image
            if ($nextImageData->hasAttribute($chosenAttribute)) {
                if (!isset($_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute])) {
                    $_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute] = 1;
                } else {
                    $_SESSION['JOURNEY_ATTRIBUTE_MAP'][$chosenAttribute]++;
                }
            }
        }
        // store the current image id, in the journey session array, check for membership incase of a page re-load
        if (!in_array($nextImageId, $_SESSION['JOURNEY_IMAGE_LIST'])) {
            $_SESSION['JOURNEY_IMAGE_LIST'][] = $nextImageId;
        }
        $commonAttributeImageDataTupleList = NULL;
        $commonAttributeImageIdList = NULL;
        $randomImageDataList = NULL;
        // find NUM_SIMILAR_CHOICES common images if possible
        $commonAttributeImageIdTupleList = ImageAttribute::loadCommonAttributeImageIdTupleList($dbConnection, $nextImageId, $_SESSION['JOURNEY_IMAGE_LIST']);
        //print( "<br/>common id list: " ); print_r( $commonAttributeImageIdTupleList ); print("<br/>" );
        shuffle($commonAttributeImageIdTupleList);
        $commonAttributeImageIdList = array();
        $commonAttributeImageDataTupleList = array();
        while (count($commonAttributeImageDataTupleList) < self::NUM_SIMILAR_CHOICES && count($commonAttributeImageIdTupleList) > 0) {
            $currentEntry = array();
            $commonAttributeImageIdTuple = array_shift($commonAttributeImageIdTupleList);
            if (!in_array($commonAttributeImageIdTuple['imageId'], $commonAttributeImageDataTupleList) && !in_array($commonAttributeImageIdTuple['imageId'], $_SESSION['JOURNEY_IMAGE_LIST'])) {
                $imageData = ImageData::loadImageDataById($dbConnection, $commonAttributeImageIdTuple['imageId']);
                //print( "<br/>Image Data: " ); print_r( $imageData ); print( '<br/>' );
                $commonAttributeImageIdList[] = $commonAttributeImageIdTuple['imageId'];
                $currentEntry['imageData'] = $imageData;
                $currentEntry['attribute'] = $commonAttributeImageIdTuple['attribute'];
                $commonAttributeImageDataTupleList[] = $currentEntry;
            }
        }
        //print( "<br/>common map: " ); print_r( $commonAttributeImageDataTupleList ); print("<br/>" );
        // add a random image to the choices list, and fill in the gaps if NUM_SIMILAR_CHOICES could not be found, if possible
        /*
          print( "<br/>commonAttributeImageDataTupleList: " ); print_r( $commonAttributeImageDataTupleList ); print( "<br/>" );
          print( "allImageIdList: " ); print_r( $allImageIdList ); print( "<br/>" );
          print( "att_map: " ); print_r( $_SESSION['JOURNEY_IMAGE_LIST'] ); print( "<br/>" );
        */
        $allImageIdList = ImageData::loadAllImageIdList($dbConnection);
        shuffle($allImageIdList);
        $randomImageIdList = array();
        while (count($randomImageIdList) + count($commonAttributeImageIdList) < self::NUM_SIMILAR_CHOICES + 1 && count($allImageIdList) > 0) {
            $imageId = array_shift($allImageIdList);
            if ($imageId != $nextImageId && !in_array($imageId, $randomImageIdList) && !in_array($imageId, $commonAttributeImageIdList) && !in_array($imageId, $_SESSION['JOURNEY_IMAGE_LIST'])) {
                $randomImageIdList[] = $imageId;
            }
        }
        if (!empty($randomImageIdList)) {
            $randomImageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $randomImageIdList);
        } else {
            $randomImageDataList = array();
        }
        // If the journey session array size has reached the number of journey steps, then set the is last
        // step flag to true, otherwise it should be false
        $IS_LAST_STEP = FALSE;
        if (count($_SESSION['JOURNEY_IMAGE_LIST']) == self::NUM_JOURNEY_STEPS) {
            $IS_LAST_STEP = TRUE;
        }
        // display the current image
        ?>
	<div class="currentJourneyImageSection">
	     <img src="<?php 
        echo UrlFormatter::formatImageUrl($nextImageData->getContentUri());
        ?>
"/>
	</div>
	<?php 
        // if this is not the last step, display further choices
        if (!$IS_LAST_STEP) {
            ?>
	    <p class="imageGridHeader">Choose Your Journey's Next Step</p>
	    <div class="centerWrapper">
	    <div class="imageGrid">
	    <?php 
            // list common choices
            foreach ($commonAttributeImageDataTupleList as $commonAttributeImageDataTuple) {
                $commonImageId = $commonAttributeImageDataTuple['imageData']->getId();
                $commonImageThumbUrl = UrlFormatter::formatImageUrl($commonAttributeImageDataTuple['imageData']->getThumbnailUri());
                $commonAttribute = $commonAttributeImageDataTuple['attribute'];
                $choiceUrl = UrlFormatter::formatRoutingItemUrl('views/JourneyStepView', array(self::GET_PARAM_NEXT_IMAGE_ID => $commonImageId, self::GET_PARAM_CHOSEN_ATTRIBUTE => $commonAttribute));
                ?>
		<a href="<?php 
                echo $choiceUrl;
                ?>
"><img src="<?php 
                echo $commonImageThumbUrl;
                ?>
"/></a>
		<?php 
            }
            // list random choices
            foreach ($randomImageDataList as $randomImageData) {
                $randomImageId = $randomImageData->getId();
                $thumbnailUrl = UrlFormatter::formatImageUrl($randomImageData->getThumbnailUri());
                $choiceUrl = UrlFormatter::formatRoutingItemUrl('views/JourneyStepView', array(self::GET_PARAM_NEXT_IMAGE_ID => $randomImageId));
                ?>
		<a href="<?php 
                echo $choiceUrl;
                ?>
"><img src="<?php 
                echo $thumbnailUrl;
                ?>
"/></a>
		<?php 
            }
            ?>
	    </div>
	    </div>
	    <?php 
        } else {
            $finishJourneyUrl = UrlFormatter::formatRoutingItemUrl('views/FinishJourneyView');
            ?>
	    <div class="finishJourneyButtonSection">
		 <a class="button" href="<?php 
            echo $finishJourneyUrl;
            ?>
">Finish Journey</a>
	    </div>
	    <?php 
        }
        parent::displayFooter();
    }
    public function processRequest(User $user = NULL)
    {
        $journeyId = RequestParser::parseRequestParam($_GET, self::GET_PARAM_JOURNEY_ID, RequestParser::PARAM_FILTER_TYPE_INT);
        $baseUrl = Settings::getSetting('APPLICATION_URL');
        if (!$journeyId) {
            header("Location: {$baseUrl}");
            exit;
        }
        // load the journey data
        $dbConnection = DbConnectionUtil::getDbConnection();
        $journeyData = Journey::loadJourneyById($dbConnection, $journeyId);
        if (!$journeyData) {
            header("Location: {$baseUrl}");
            exit;
        }
        // load the images from the journey
        $imageDataList = ImageData::loadImageDataListByIdSet($dbConnection, $journeyData->getImageIdList());
        parent::displayHeader($user, 'Journey Details');
        ?>
	<div class="imageDetailsView">
	     <label for="journey_name_field">Journey Name</label>
	     <br/>
             <span id="journey_name_field" class="imageDetailsViewField"><?php 
        echo $journeyData->getTitle();
        ?>
</span>
	     <br/>
	     <label for="journey_creation_date_field">Journey Date</label>
             <br/>
             <span id="journey_creation_date_field" class="imageDetailsViewField"><?php 
        echo $journeyData->getCreationDate();
        ?>
</span>
	     <br/>
             <label for="journey_comments_field">Journey Comments</label>
             <br/>
             <p id="journey_comments_field" class="imageDetailsViewField"><?php 
        echo $journeyData->getComments();
        ?>
</p>
	</div>
        <div class="imageGrid">
        <?php 
        foreach ($imageDataList as $imageData) {
            $imageDetailsUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId()));
            $thumbnailUrl = UrlFormatter::formatImageUrl($imageData->getThumbnailUri());
            ?>
	       <a target="_blank" href="<?php 
            echo $imageDetailsUrl;
            ?>
"><img src="<?php 
            echo $thumbnailUrl;
            ?>
"/></a>
	       <?php 
        }
        ?>
        </div>
	
	<?php 
        parent::displayFooter();
    }
 /**
  * This abstract function performs the processing of the user request.
  * @param User $user The requesting user. If the user is not null, then by convention
  * actions will assume the user is authenticated, otherwise not.
  * @throws Exception If an error was encountered while processing this request, an exception
  * will be thrown.
  * @return void
  */
 public function processRequest(User $user = NULL)
 {
     // if image id was specified, parse it, attempt to load an image data object using the id
     $imageId = RequestParser::parseRequestParam($_REQUEST, EditImageAction::GET_PARAM_IMAGE_ID, RequestParser::PARAM_FILTER_TYPE_INT);
     $imageData = NULL;
     if ($imageId != NULL) {
         $imageData = ImageData::loadImageDataById(DbConnectionUtil::getDbConnection(), $imageId);
     }
     // otherwise create a new image data object
     if ($imageData == NULL) {
         $imageData = new ImageData();
         $imageData->setSubmitterUserId($user->getId());
     }
     // set the fields in the image data object
     $author = NULL;
     if (isset($_POST['author'])) {
         $author = $_POST['author'];
     }
     if ($author != NULL) {
         $imageData->setAuthor($author);
     }
     $title = NULL;
     if (isset($_POST['title'])) {
         $title = $_POST['title'];
     }
     if ($title != NULL) {
         $imageData->setTitle($title);
     }
     $year = NULL;
     if (isset($_POST['year'])) {
         $year = $_POST['year'];
     }
     if ($year != NULL) {
         $imageData->setYear($year);
     }
     // update attributes list
     $attributeString = $_POST[EditImageAction::POST_PARAM_ATTRIBUTE_LIST];
     if (!empty($attributeString)) {
         $attributeStringList = explode(",", $attributeString);
     } else {
         $attributeStringList = array();
     }
     // add new attributes
     foreach ($attributeStringList as $attString) {
         if ($attString != "") {
             if (!$imageData->hasAttribute($attString)) {
                 $imageData->addAttributeByString($attString);
             }
         }
     }
     $dbConnection = DbConnectionUtil::getDbConnection();
     // remove deleted ones
     $attributeList = $imageData->getAttributeList();
     foreach ($attributeList as $attribute) {
         if (!in_array($attribute->getAttribute(), $attributeStringList)) {
             $imageData->removeAttributeBystring($attribute->getAttribute());
             $attribute->delete($dbConnection);
         }
     }
     // save the image data object
     $imageData->save($dbConnection);
     // if image data was uploaded, process the image uploads and save again
     if (!empty($_FILES[EditImageAction::POST_PARAM_THUMBNAIL]['name'])) {
         $thumbnailUri = $this->processImageUpload('image_data_thumbs', $imageData->getId(), EditImageAction::POST_PARAM_THUMBNAIL);
         $imageData->setThumbnailUri($thumbnailUri);
         $imageData->save($dbConnection);
     }
     if (!empty($_FILES[EditImageAction::POST_PARAM_FILE]['name'])) {
         $fileUri = $this->processImageUpload('image_data', $imageData->getId(), EditImageAction::POST_PARAM_FILE);
         $imageData->setContentUri($fileUri);
         $imageData->save($dbConnection);
     }
     // redirect the user to the image viewing page
     $getParamMap = array(ImageDetailsView::GET_PARAM_IMAGE_ID => $imageData->getId());
     $imageDetailsViewUrl = UrlFormatter::formatRoutingItemUrl('views/ImageDetailsView', $getParamMap);
     header("Location: {$imageDetailsViewUrl}");
 }
 /**
  * Use this method to access the body parameters of the request (e.g. $_POST).
  *
  *     $password = $this->bodyParameter('password')->string()->required()
  *
  * @param string $name
  * @return TypeParser
  */
 protected function bodyParameter($name)
 {
     return $this->bodyParser->get($name);
 }