/** * Import remote file * * @param string $service Service name (google or dropbox) * @param integer $uid User ID * @param array $remote Remote resource array * @param string $fpath File path relative to repo path * @param string $path Project repo path * @param string $ext Extension * @param boolean $getContent Output file content? Or write to file * * @return string or boolean */ public function importFile($service = 'google', $uid = 0, $remote = array(), $fpath = '', $path = '', $ext = '', $getContent = false) { if (empty($remote) || !$fpath || !is_dir($path) || !isset($remote['exportLinks'])) { return false; } $url = ''; $default_type = Google::getGoogleExportType($ext); foreach ($remote['exportLinks'] as $type => $link) { if ($type == $default_type) { $url = $link; } } if (!$url) { return false; } // Get content $fc = $this->sendHttpRequest($service, $uid, $url); if ($getContent == true) { return $fc; } // Clean up data from Windows characters - important! if ($ext == 'tex') { $fc = preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $fc); } if ($this->fetchFile($fc, $fpath, $path)) { return true; } return false; }