Ejemplo n.º 1
0
    /**
     * Render the view to standard output
     *
     * @access public
     * @return void
     */
    public function render()
    {
        if ($this->photo->get('status') != 0) {
            echo '<p class="alert alert-danger lead"><strong>Notice:</strong> This photo is not publicly viewable</p>';
        }
        $this->referrer = str_replace(constant('BASE_URL'), '', $this->referrer);
        $this->referrer = preg_replace('|^/|', '', $this->referrer);
        //todo, photo model needs to know referrer
        $photoPrev = $this->photo->getPrevious();
        $photoNext = $this->photo->getNext();
        // Get stuff related to the current user
        if ($this->currentUser->isLoggedIn) {
            $rating = $avg = Models\Database::selectOne('ratings', 'AVG(rating)', 'id=' . $this->photo->get('id') . " AND username='******'");
        } else {
            $rating = $avg = Models\Database::selectOne('ratings', 'AVG(rating)', 'id=' . $this->photo->get('id') . " AND user_ip='" . $this->currentUser->remoteAddr . "'");
        }
        ?>

		<nav class="navbar navbar-light bg-faded navbar-fixed-bottom" style="background:rgba(255,255,255,0.4)">
			<div class="container">
				<form class="form-inline pull-xs-left" method=POST name="form" style="margin-right:10px">
					<input type="hidden" name="action" value="<?php 
        echo $rating ? 'unfavorite' : 'favorite';
        ?>
">
					<?php 
        $count = $this->photo->getLikeCount();
        ?>
					<button class="btn btn-link" type="submit" style="padding:2px">
				        <span class="fa-stack">
				            <i class="fa fa-star<?php 
        echo $rating ? '' : '-o';
        ?>
 fa-stack-2x" style="color:gold"></i>
				            <strong class="fa-stack-1x" style="font-size:0.7em;color:black"><?php 
        echo $count ? $count : '';
        ?>
</strong>
				        </span>				
					</button>
				</form>
			    <a href="<?php 
        echo $this->photo->getMediaURL('photo');
        ?>
"
			        class="btn btn-link pull-xs-left"
			        title="<?php 
        echo $this->photo->get('width');
        ?>
 x <?php 
        echo $this->photo->get('height');
        ?>
px"
					style="margin-right:10px"
				>
			        <i class="fa fa-arrows-alt"></i>
			    </a>
			    <a href="<?php 
        echo $this->contextUrl;
        ?>
"
			        class="btn btn-link pull-xs-left"
			        title="Close"
					style="margin-right:10px"
				>
			        <i class="fa fa-times"></i>
			    </a>
		        <span class="navbar-brand"><?php 
        echo htmlspecialchars($this->openGraphObject->title);
        ?>
</span>
			</div>
		</nav>
 
<div
	id="mainPic" 
	style="position:absolute;top:0;left:0;width:100%;height:100%;background:url(<?php 
        echo $this->photo->getMediaURL('scaled');
        ?>
);background-size:contain;background-repeat:no-repeat;background-position:center"
>

	<img
		src="<?php 
        echo $this->photo->getMediaURL('scaled');
        ?>
"
		alt="<?php 
        echo htmlentities($this->photo->get('description'));
        ?>
"
		style="display:none"
	>
</div>

<div class="container" style="position:absolute;top:100%;height:100%;">
        <h3>Information</h3>
        <dl class="dl-horizontal">
            <?php 
        if ($this->photo->get('username')) {
            echo '         <dt>Author</dt><dd>' . $this->photo->get('username') . '</dd>';
        }
        if ($exif = $this->photo->getEXIF()) {
            foreach ($exif as $key => $val) {
                if ($key == "Location") {
                    echo "         <dt>{$key}</dt><dd><a href=\"http://maps.google.com/maps?q={$val}\">{$val}</a></dd>\n";
                } else {
                    if ($key == "Camera Model") {
                        echo "         <dt>{$key}</dt><dd><a href=\"http://pbase.com/cameras/{$val}\">{$val}</a></dd>\n";
                    } else {
                        echo "         <dt>{$key}</dt><dd>{$val}</dd>\n";
                    }
                }
            }
        }
        ?>
        </dl>
</div>
 
<?php 
        // Cache the next image the user is likely to look at
        if ($photoNext) {
            echo '<img style="display:none" src="' . htmlspecialchars($photoNext->getMediaURL('scaled')) . '" alt="hidden photo">';
        }
    }