示例#1
0
 public function getPath()
 {
     $path = parent::getPath();
     switch (dirname($path)) {
         case 'html':
             return basename($path);
         case 'css/custom':
         case 'css/patternlab':
             $path = $this->makePath(['css', basename($path)]);
         default:
             return $this->makePath(['styleguide', $path]);
     }
 }
示例#2
0
<?php

$file_input = elgg_extract('file', $_FILES);
$filename = $file_input['name'];
if (empty($filename) || elgg_extract('error', $file_input) !== 0) {
    register_error(elgg_echo('upload:error:unknown'));
    forward(REFERER);
}
$file = new \AssetFile();
$file->setFilename('asset_library/' . $filename);
$file->open('write');
$file->write(get_uploaded_file('file'));
$file->close();
$file->save();
$file->mimetype = (new \Elgg\Filesystem\MimeTypeDetector())->getType($file->getFilenameOnFilestore(), $file->getMimeType());
$file->simpletype = elgg_get_file_simple_type($file->mimetype);
$file->save();
forward(REFERER);
示例#3
0
 public function unzipTmp($id, $relative = false)
 {
     $zipPath = realpath(WWW_ROOT . AssetFile::url($id));
     $base_folder = WWW_ROOT . "files/tmpgal/" . DS;
     // setup dir names absolute and relative
     $folder = explode(".", $zipPath);
     $type = array_pop($folder);
     $folder = time();
     $folder_url = $base_folder . DS . $folder;
     //make sure our folders are there
     if (!is_dir($base_folder)) {
         mkdir($base_folder);
     }
     if (!is_dir($folder_url)) {
         mkdir($folder_url);
     }
     $zip = zip_open($zipPath);
     if (!is_resource($zip)) {
         die($this->zipFileErrMsg($zip));
     }
     $files = array();
     $found_image = false;
     $c = 0;
     while ($zip_entry = zip_read($zip)) {
         $name = explode('/', zip_entry_name($zip_entry));
         $name = array_pop($name);
         $type = array_pop(explode('.', $name));
         if (in_array($type, array('png', 'gif', 'jpg', 'jpeg'))) {
             if (is_resource($zip_entry) && $name != "" && substr($name, 0, 2) != "._") {
                 $file = $folder_url . DS . $c . '.' . $type;
                 file_put_contents($file, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
                 if ($relative) {
                     $files[] = str_replace('///', '/', array_pop(explode('webroot', $file)));
                 } else {
                     $files[] = 'http://' . $_SERVER['HTTP_HOST'] . DS . str_replace('//', '/', array_pop(explode('webroot', $file)));
                 }
             }
         }
         $c++;
     }
     zip_close($zip);
     return $files;
 }