本文整理汇总了PHP中zip_packer::extract_to_pathname方法的典型用法代码示例。如果您正苦于以下问题:PHP zip_packer::extract_to_pathname方法的具体用法?PHP zip_packer::extract_to_pathname怎么用?PHP zip_packer::extract_to_pathname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zip_packer
的用法示例。
在下文中一共展示了zip_packer::extract_to_pathname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extract_archive
public static function extract_archive($archive_path, $to_path = '')
{
$to_path = empty($to_path) ? MoodleUtil::create_temp_directory() : $to_path;
$zipper = new zip_packer();
if ($zipper->extract_to_pathname($archive_path, $to_path)) {
return $to_path;
} else {
return false;
}
}
示例2: geogebra_get_js_from_geogebra
/**
* Execute Javascript that is embedded in the geogebra file, if it exists
* File must be named geogebra_javascript.js
* @param object $context Of the activity to get the files
* @param object $geogebra object with the activity info
*/
function geogebra_get_js_from_geogebra($context, $geogebra)
{
global $CFG;
$content = false;
if (geogebra_is_valid_external_url($geogebra->url)) {
require_once "{$CFG->libdir}/filestorage/zip_packer.php";
// Prepare tmp dir (create if not exists, download ggb file...)
$dirname = 'mod_geogebra_' . time();
$tmpdir = make_temp_directory($dirname);
if (!$tmpdir) {
debugging("Cannot create temp directory {$dirname}");
return;
}
$materialid = geogebra_get_id($geogebra->url);
if ($materialid) {
$ggbfile = "http://tube.geogebra.org/material/download/format/file/id/{$materialid}";
} else {
$ggbfile = $geogebra->url;
}
$filename = pathinfo($ggbfile, PATHINFO_FILENAME);
$tmpggbfile = tempnam($tmpdir, $filename . '_');
// Download external GGB and extract javascript file
if (!download_file_content($ggbfile, null, null, false, 300, 20, false, $tmpggbfile)) {
debugging("Error copying from {$ggbfile}");
return;
}
// Extract geogebra js from GGB file
$zip = new zip_packer();
$extract = $zip->extract_to_pathname($tmpggbfile, $tmpdir, array('geogebra_javascript.js'));
if ($extract && $extract['geogebra_javascript.js']) {
unlink($tmpggbfile);
} else {
@unlink($tmpggbfile);
@rmdir($tmpdir);
debugging("Cannot open zipfile {$tmpggbfile}");
return;
}
$content = file_get_contents($tmpdir . '/geogebra_javascript.js');
// Delete temporary files
unlink($tmpdir . '/geogebra_javascript.js');
rmdir($tmpdir);
} else {
$fs = get_file_storage();
$file = $fs->get_file($context->id, 'mod_geogebra', 'extracted_files', 0, '/', 'geogebra_javascript.js');
if ($file) {
$content = $file->get_content();
}
}
if (empty($content)) {
debugging("Empty content");
return;
}
echo '<script type="text/javascript">
if (typeof ggbApplet == \'undefined\') {
ggbApplet = document.ggbApplet;
}
' . $content . '</script>';
}