Ejemplo n.º 1
0
 /**
  * getFileForPhotoWithScale function.
  * 
  * @access private
  * @param Models\Photo $photo
  * @param mixed $scale
  * @return [$file, $temp, $mtime]
  */
 private static function getFileForPhotoWithScale(Models\Photo $photo, $scale)
 {
     $extension = $photo->extension;
     $bucket = 'other';
     $path = '';
     if ($scale == 'photo') {
         if ($photo->get('modified')) {
             $path = '/' . $photo->get('id') . '_mod.' . $extension;
         } else {
             $bucket = 'photo';
             $path = rtrim('/' . ltrim($photo->get('path'), '/'), '/') . '/' . $photo->get('filename');
         }
     } elseif ($scale == 'scaled') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'scaledsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif ($scale == 'thumbnail') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'thumbsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif (is_numeric($scale)) {
         $valid = preg_split('/[, ]+/', Models\Preferences::valueForModuleWithKey('CameraLife', 'optionsizes'));
         if (!in_array($scale, $valid)) {
             throw new \Exception('This image size has not been allowed');
         }
         $path = "/{$photo->get('id')}_{$scale}.{$extension}";
     } else {
         throw new \Exception('Missing or bad size parameter');
     }
     $fileStore = Models\FileStore::fileStoreWithName($bucket);
     list($file, $temp, $mtime) = $fileStore->getFile($path);
     if (!$file) {
         $photo->generateThumbnail();
         list($file, $temp, $mtime) = $fileStore->getFile($path);
     }
     return [$file, $temp, $mtime];
 }
Ejemplo n.º 2
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">';
        }
    }