Beispiel #1
0
 public static function storeMedias($item_id, $type, $files, $source_path, $target_path, $table_name)
 {
     $db = JFactory::getDbo();
     $destination = DJCatalog2FileHelper::getDestinationFolder($target_path, $item_id, $type);
     $sub_path = DJCatalog2FileHelper::getDestinationPath($item_id, $type);
     if (!JFolder::exists($destination)) {
         $destExist = JFolder::create($destination, 0755);
     } else {
         $destExist = true;
     }
     if ($destExist && !empty($files)) {
         $ordering = 1;
         foreach ($files as $file) {
             $file = trim($file);
             if ($file && JFile::exists($source_path . DS . $file)) {
                 $obj = new stdClass();
                 $obj->id = null;
                 $obj->fullname = DJCatalog2FileHelper::createFileName($file, $destination);
                 $obj->name = JFile::stripExt($obj->fullname);
                 $obj->ext = JFile::getExt($obj->fullname);
                 $obj->item_id = $item_id;
                 $obj->path = $sub_path;
                 $obj->fullpath = $sub_path . '/' . $obj->fullname;
                 $obj->type = $type;
                 $obj->caption = JFile::stripExt($file);
                 $obj->ordering = $ordering++;
                 if (JFile::copy($source_path . DS . $file, $destination . DS . $obj->fullname)) {
                     $db->insertObject($table_name, $obj, 'id');
                 }
             }
         }
     }
 }
Beispiel #2
0
 public static function getDestinationPath($itemid, $itemtype)
 {
     return parent::getDestinationPath($itemid, $itemtype);
 }