Beispiel #1
0
 public function __construct(Unsee_Hash $hash, $imgKey = null)
 {
     $newImage = is_null($imgKey);
     if ($newImage) {
         $imgKey = uniqid();
     }
     parent::__construct($hash->key . '_' . $imgKey);
     if ($newImage) {
         $keys = Unsee_Image::keys($hash->key . '*');
         $this->num = count($keys);
         $this->expireAt(time() + $hash->ttl());
     }
     $this->setSecureParams();
 }
Beispiel #2
0
 /**
  * Returns an array of image models assigned to the hash
  * @return \Unsee_Image[]
  */
 public function getImages()
 {
     // read files in directory
     $imagesKeys = Unsee_Image::keys($this->key . '*');
     $imageDocs = array();
     foreach ($imagesKeys as $key) {
         list(, $imgKey) = explode('_', $key);
         $imageDocs[] = new Unsee_Image($this, $imgKey);
     }
     usort($imageDocs, function ($a, $b) {
         if ($a->num === $b->num) {
             return 0;
         }
         return $a->num < $b->num ? -1 : 1;
     });
     return $imageDocs;
 }