public function cloneContentFile($file, $fromId, $toId) {
    // Determine source path
    if ($fromId === 'editor') {
      $sourcepath = $this->getEditorPath();
    }
    else {
      $sourcepath = "{$this->path}/content/{$fromId}";
    }
    $sourcepath .= '/' . $file;

    // Determine target path
    $filename = basename($file);
    $filedir = str_replace($filename, '', $file);
    $targetpath = "{$this->path}/content/{$toId}/{$filedir}";

    // Make sure it's ready
    self::dirReady($targetpath);

    $targetpath .= $filename;

    // Check to see if source exist and if target doesn't
    if (!file_exists($sourcepath) || file_exists($targetpath)) {
      return; // Nothing to copy from or target already exists
    }

    copy($sourcepath, $targetpath);
  }
public function cloneContentFile($file, $fromId, $toId) {
    // Determine source path
    if ($fromId === 'editor') {
      $sourcepath = $this->getEditorPath();
    }
    else {
      $sourcepath = "{$this->path}/content/{$fromId}";
    }
    $sourcepath .= '/' . $file;

    // Determine target path
    $filename = basename($file);
    $filedir = str_replace($filename, '', $file);
    $targetpath = "{$this->path}/content/{$toId}/{$filedir}";

    // Make sure it's ready
    self::dirReady($targetpath);

    $targetpath .= $filename;

    // Check to see if source exist and if target doesn't
    if (!file_exists($sourcepath) || file_exists($targetpath)) {
      return; // Nothing to copy from or target already exists
    }

    copy($sourcepath, $targetpath);
  }
public function cloneContentFile ( $ file , $ fromId , $ toId ) { // Determine source path if ( $ fromId === 'editor' ) { $ sourcepath = $ this -> getEditorPath ( ) ; } else { $ sourcepath = "{$this->path}/content/{$fromId}" ; } $ sourcepath .= '/' . $ file ; // Determine target path $ filename = basename ( $ file ) ; $ filedir = str_replace ( $ filename , '' , $ file ) ; $ targetpath = "{$this->path}/content/{$toId}/{$filedir}" ; // Make sure it's ready self :: dirReady ( $ targetpath ) ; $ targetpath .= $ filename ; // Check to see if source exist and if target doesn't if ( ! file_exists ( $ sourcepath ) || file_exists ( $ targetpath ) ) { return ; // Nothing to copy from or target already exists } copy ( $ sourcepath , $ targetpath ) ; }
Copy a file from another content or editor tmp dir.
Used when copy pasting content in H5P Editor.

@param string $file path + name
@param string|int $fromid Content ID or 'editor' string
@param int $toid Target Content ID
Copy a file from another content or editor tmp dir . Used when copy pasting content in H5P Editor .