Guest User

copy images in gallery3

a guest
Dec 2nd, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         function _copy_to ($album_id, $item) {
  2.                 $album_to   = ORM::factory("item", $album_id);
  3.                 $album_from = ORM::factory("item", $item->parent_id);
  4.  
  5.                 $to_dir   = str_replace(dirname($album_to->file_path()), "", $album_to->file_path());
  6.                 $from_dir = str_replace(dirname($album_from->file_path()), "", $album_from->file_path());
  7.  
  8.                 $from = $item->file_path();
  9.                 $to = str_replace($from_dir, $to_dir, $item->file_path());
  10.                 $to_original = $to;
  11.                 copy($from, $to);
  12.                 chmod($to, 0777);
  13.  
  14.                 $from = str_replace("albums", "thumbs", $from);
  15.                 $to   = str_replace("albums", "thumbs", $to);
  16.                 copy($from, $to);
  17.                 chmod($to, 0777);
  18.  
  19.                 $from = str_replace("thumbs", "resizes", $from);
  20.                 $to   = str_replace("thumbs", "resizes", $to);
  21.                 copy($from, $to);
  22.                 chmod($to, 0777);
  23.  
  24.                 $copy = ORM::factory("item");
  25.                 $copy->name      = $item->name;
  26.                 $copy->title     = $item->title;
  27.                 $copy->type      = $item->type;
  28.                 $copy->parent_id = $album_to->id;
  29.                 $copy->set_data_file($to_original);
  30.                 $copy->save();
  31.  
  32.         }
Advertisement
Add Comment
Please, Sign In to add comment