示例#1
0
 /**
  * Gets the class that will be used to determine the crop offset for the image
  *
  * @since 2.0
  * @return SLIRCropper
  */
 public final function getCropperClass()
 {
     $configClass = \SLIR\SLIR::getConfigClass();
     $cropClass = 'SLIRCropper' . ucfirst($this->getCropper());
     $fileName = $configClass::$pathToSLIR . "/core/Libs/GD/Croppers/{$cropClass}.php";
     $class = '\\SLIR\\Libs\\GD\\Croppers\\SLIRCropper' . ucfirst($this->getCropper());
     if (!file_exists($fileName)) {
         throw new \RuntimeException('The requested cropper could not be found: ' . $fileName);
     }
     return new $class();
 }
示例#2
0
 /**
  * @return string
  * @since 2.0
  */
 public function getCropper()
 {
     $configClass = \SLIR\SLIR::getConfigClass();
     if ($this->cropper !== null) {
         return $this->cropper;
     } else {
         return $configClass::$defaultCropper;
     }
 }
示例#3
0
文件: SLIR.php 项目: rezozero/slir
 /**
  * Serves headers for file for optimal browser caching
  *
  * @since 2.0
  * @param string $lastModified Time when file was last modified in 'D, d M Y H:i:s' format
  * @param string $mimeType
  * @param integer $fileSize
  * @param string $slirHeader
  * @return boolean true to continue, false to stop
  */
 private function serveHeaders($lastModified, $mimeType, $fileSize, $slirHeader)
 {
     $configClass = SLIR::getConfigClass();
     $this->header("Last-Modified: {$lastModified}");
     $this->header("Content-Type: {$mimeType}");
     $this->header("Content-Length: {$fileSize}");
     // Lets us easily know whether the image was rendered from scratch,
     // from the cache, or served directly from the source image
     $this->header("X-Content-SLIR: {$slirHeader}");
     // Keep in browser cache how long?
     $this->header(sprintf('Expires: %s GMT', gmdate('D, d M Y H:i:s', time() + $configClass::$browserCacheTTL)));
     // Public in the Cache-Control lets proxies know that it is okay to
     // cache this content. If this is being served over HTTPS, there may be
     // sensitive content and therefore should probably not be cached by
     // proxy servers.
     $this->header(sprintf('Cache-Control: max-age=%d, public', $configClass::$browserCacheTTL));
     return $this->doConditionalGet($lastModified);
     // The "Connection: close" header allows us to serve the file and let
     // the browser finish processing the script so we can do extra work
     // without making the user wait. This header must come last or the file
     // size will not properly work for images in the browser's cache
     //$this->header('Connection: close');
 }