예제 #1
0
 /**
  * @param $filename
  * @param $path
  * @param null $title
  * @param null $description
  * @return RokGallery_Model_File
  */
 public static function &createNew($filename, $path, $title = null, $description = null)
 {
     $file = new RokGallery_Model_File();
     $file->filename = $filename;
     $file->guid = RokGallery_Helper::createUUID();
     if (!(file_exists($path) && is_readable($path))) {
         throw new RokGallery_Exception(rc__('ROKGALLERY_UNABLE_TO_GET_MD5_OF_FILE_N', $path));
     }
     $file->md5 = md5_file($path);
     if (empty($title)) {
         $title = @pathinfo($filename, PATHINFO_FILENAME);
         $title = str_replace('_', ' ', $title);
     }
     $file->title = $title;
     $file->filesize = @filesize($path);
     $file->type = strtolower(@pathinfo($filename, PATHINFO_EXTENSION));
     $file->description = $description;
     return $file;
 }
예제 #2
0
 /**
  * @param RokGallery_Model_File $file
  * @param string $title
  * @param string|null $caption
  * @param bool $publish
  * @param bool $admin_thumb
  * @return RokGallery_Model_Slice
  */
 public static function &createNew(RokGallery_Model_File &$file, $title = null, $caption = null, $publish = false, $admin_thumb = false)
 {
     $slice = new RokGallery_Model_Slice();
     $slice->guid = RokGallery_Helper::createUUID();
     $slice->title = $title;
     $slice->caption = $caption;
     $slice->admin_thumb = $admin_thumb;
     $slice->published = $publish;
     $file->Slices[] = $slice;
     return $slice;
 }