当前位置: 首页>>代码示例>>PHP>>正文


PHP zip_packer::extract_to_pathname方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:jmvedrine,项目名称:moodle-qformat_imsqti21,代码行数:10,代码来源:moodle_util.class.php

示例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>';
}
开发者ID:ninelanterns,项目名称:moodle-mod_geogebra,代码行数:64,代码来源:locallib.php


注:本文中的zip_packer::extract_to_pathname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。