showing download file link only when file exists
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/026bb9d0 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/026bb9d0 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/026bb9d0 Branch: refs/heads/dreg-gateway Commit: 026bb9d09ac2b941b8dc1f0e45056a3195136c26 Parents: dc556d7 Author: scnakandala <[email protected]> Authored: Tue Apr 4 16:01:29 2017 -0400 Committer: scnakandala <[email protected]> Committed: Tue Apr 4 16:01:29 2017 -0400 ---------------------------------------------------------------------- app/libraries/ExperimentUtilities.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/026bb9d0/app/libraries/ExperimentUtilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/ExperimentUtilities.php b/app/libraries/ExperimentUtilities.php index 8248851..81f44f8 100755 --- a/app/libraries/ExperimentUtilities.php +++ b/app/libraries/ExperimentUtilities.php @@ -921,14 +921,19 @@ class ExperimentUtilities break; } } - $fileName = basename($currentOutputPath); - }else{ + $path = parse_url($currentOutputPath); + if(file_exists($path)){ + $fileName = basename($currentOutputPath); + echo '<p>' . $output->name . ': <a target="_blank" href="' . URL::to("/") + . '/download/?id=' . urlencode($output->value) . '">' . $fileName + . ' <span class="glyphicon glyphicon-new-window"></span></a></p>'; + } + }else { $fileName = basename($output->value); + echo '<p>' . $output->name . ': <a target="_blank" href="' . URL::to("/") + . '/download/?id=' . urlencode($output->value) . '">' . $fileName + . ' <span class="glyphicon glyphicon-new-window"></span></a></p>'; } - echo '<p>' . $output->name . ': <a target="_blank" href="' . URL::to("/") - . '/download/?id=' . urlencode($output->value) . '">' . $fileName - . ' <span class="glyphicon glyphicon-new-window"></span></a></p>'; - } } elseif ($output->type == DataType::STRING) { echo '<p>' . $output->value . '</p>';
