Internal implementation of file picker rendering.

@param file_picker $fp
@return string
552928
public function render_file_picker(file_picker $fp) {
        global $CFG, $OUTPUT, $USER;
        $options = $fp->options;
        $client_id = $options->client_id;
        $strsaved = get_string('filesaved', 'repository');
        $straddfile = get_string('openpicker', 'repository');
        $strloading  = get_string('loading', 'repository');
        $strdndenabled = get_string('dndenabled_inbox', 'moodle');
        $strdroptoupload = get_string('droptoupload', 'moodle');
        $icon_progress = $OUTPUT->pix_icon('i/loading_small', $strloading).'';

        $currentfile = $options->currentfile;
        if (empty($currentfile)) {
            $currentfile = '';
        } else {
            $currentfile .= ' - ';
        }
        if ($options->maxbytes) {
            $size = $options->maxbytes;
        } else {
            $size = get_max_upload_file_size();
        }
        if ($size == -1) {
            $maxsize = '';
        } else {
            $maxsize = get_string('maxfilesize', 'moodle', display_size($size));
        }
        if ($options->buttonname) {
            $buttonname = ' name="' . $options->buttonname . '"';
        } else {
            $buttonname = '';
        }
        $html = <<<EOD
<div class="filemanager-loading mdl-align" id='filepicker-loading-{$client_id}'>
$icon_progress
</div>
<div id="filepicker-wrapper-{$client_id}" class="mdl-left w-100" style="display:none">
    <div>
        <input type="button" class="btn btn-secondary fp-btn-choose" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
        <span> $maxsize </span>
    </div>
EOD;
        if ($options->env != 'url') {
            $html .= <<<EOD
    <div id="file_info_{$client_id}" class="mdl-left filepicker-filelist" style="position: relative">
    <div class="filepicker-filename">
        <div class="filepicker-container">$currentfile<div class="dndupload-message">$strdndenabled <br/><div class="dndupload-arrow"></div></div></div>
        <div class="dndupload-progressbars"></div>
    </div>
    <div><div class="dndupload-target">{$strdroptoupload}<br/><div class="dndupload-arrow"></div></div></div>
    </div>
EOD;
        }
        $html .= '</div>';
        return $html;
    }
1131379
public function folder_selector($p = array())
    {
        $realnames = $this->config->get('show_real_foldernames');
        $p += array('maxlength' => 100, 'realnames' => $realnames, 'is_escaped' => true);
        $a_mailboxes = array();
        $storage = $this->get_storage();

        if (empty($p['folder_name'])) {
            $p['folder_name'] = '*';
        }

        if ($p['unsubscribed']) {
            $list = $storage->list_folders('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']);
        }
        else {
            $list = $storage->list_folders_subscribed('', $p['folder_name'], $p['folder_filter'], $p['folder_rights']);
        }

        $delimiter = $storage->get_hierarchy_delimiter();

        if (!empty($p['exceptions'])) {
            $list = array_diff($list, (array) $p['exceptions']);
        }

        if (!empty($p['additional'])) {
            foreach ($p['additional'] as $add_folder) {
                $add_items = explode($delimiter, $add_folder);
                $folder    = '';
                while (count($add_items)) {
                    $folder .= array_shift($add_items);

                    // @TODO: sorting
                    if (!in_array($folder, $list)) {
                        $list[] = $folder;
                    }

                    $folder .= $delimiter;
                }
            }
        }

        foreach ($list as $folder) {
            $this->build_folder_tree($a_mailboxes, $folder, $delimiter);
        }

        $select = new html_select($p);

        if ($p['noselection']) {
            $select->add(html::quote($p['noselection']), '');
        }

        $this->render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames'], 0, $p);

        return $select;
    }
1108870
static function preview( $args )
    {
        $http = eZHTTPTool::instance();
        $handler = self::getHandler( $args );
        if ( !$handler->canUpload() )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader',
                    'You are not allowed to upload a file.'
                )
            );
        }

        $file = $http->postVariable( 'UploadFile', false );
        $fileHandler = eZClusterFileHandler::instance();
        if ( $file === false
                || !$fileHandler->fileExists( $file )
                || !$fileHandler->fileFetch( $file ) )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader', 'Unable to retrieve the uploaded file.'
                )
            );
        }
        else
        {
            $tmpFile = eZSys::cacheDirectory() . '/' .
                        eZINI::instance()->variable( 'FileSettings', 'TemporaryDir' ) . '/' .
                        str_replace(
                            array( '/', '\\' ), '_',
                            $http->postVariable( 'UploadOriginalFilename' )
                        );
            eZFile::rename( $file, $tmpFile, true );
            $fileHandler->fileDelete( $file );
            $fileHandler->fileDeleteLocal( $file );
        }

        $contentObject = $handler->createObject(
            $tmpFile,
            $http->postVariable( 'UploadLocation', false ),
            $http->postVariable( 'UploadName', '' )
        );
        unlink( $tmpFile );

        $tpl = eZTemplate::factory();
        $tpl->setVariable( 'object', $contentObject );
        return array(
            'meta_data' => $handler->serializeObject( $contentObject ),
            'html' => $tpl->fetch( 'design:ajaxuploader/preview.tpl' )
        );
    }
819140
private function readFlvHeader($fp)
    {
        $result = null;
        $flvHeaderChunk = @fread($fp, 9); // 3 bytes signature + 1 byte version + 1 byte flags + 4 bytes data offset
        if ($flvHeaderChunk !== false && isset($flvHeaderChunk[8])) {
            if (substr($flvHeaderChunk, 0, 3) === 'FLV') { // Signature ok
                $version = $this->parseUI8($flvHeaderChunk[3]);
                if ($version === 1) { // Version ok
                    $flags = $this->parseUI8($flvHeaderChunk[4]); // Bit 0x01 set: has video; bit 0x04: has audio
                    $dataOffset = $this->parseUI32(substr($flvHeaderChunk, 5, 4));
                    $result = [
                        'version' => $version,
                        'flags' => $flags,
                        'dataOffset' => $dataOffset,
                    ];
                }
            }
        }

        return $result;
    }
1369402
function fp()
    {
        if ( !isset( $GLOBALS['eZMutex_FP_' . $this->FileName] ) ||
             $GLOBALS['eZMutex_FP_' . $this->FileName] === false )
        {
            $GLOBALS['eZMutex_FP_' . $this->FileName] = fopen( $this->FileName, 'w' );
            if ( $GLOBALS['eZMutex_FP_' . $this->FileName] === false )
            {
                eZDebug::writeError( 'Failed to open file: ' . $this->FileName );
            }
        }
        return $GLOBALS['eZMutex_FP_' . $this->FileName];
    }
472627
public function renderFile(File $file)
    {
        return $this->make(
            $file->getFileInfo()->getRelativePath().
            DIRECTORY_SEPARATOR.
            pathinfo($file->getFileInfo()->getFilename(), PATHINFO_FILENAME)
        )->renderFile($file);
    }
1067721
public static function get_filepicker_options($context, $draftitemid) {
        return [
                'image' => self::specific_filepicker_options(['image'], $draftitemid, $context),
                'media' => self::specific_filepicker_options(['video', 'audio'], $draftitemid, $context),
                'link'  => self::specific_filepicker_options('*', $draftitemid, $context),
            ];
    }
727047
protected function _GetResponse($fp, $client_ver)
    {
        $status = '';
        $response = '';
        $len = 0;
        $ver = '';

        $header = fread($fp, 8);
        if (strlen($header) == 8) {
            list($status, $ver, $len) = array_values(unpack('n2a/Nb', $header));
            $left = $len;
            while ($left > 0 && !feof($fp)) {
                $chunk = fread($fp, min(8192, $left));
                if ($chunk) {
                    $response .= $chunk;
                    $left -= strlen($chunk);
                }
            }
        }
        if ($this->_socket === false) {
            fclose($fp);
        }

        // check response
        $read = strlen($response);
        if (!$response || $read != $len) {
            $this->_error = $len
                ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)"
                : 'received zero-sized searchd response';

            return false;
        }

        // check status
        if ($status == SEARCHD_WARNING) {
            list($temp, $wlen) = unpack('N*', substr($response, 0, 4));
            unset($temp);
            $this->_warning = substr($response, 4, $wlen);

            return substr($response, 4 + $wlen);
        }
        if ($status == SEARCHD_ERROR) {
            $this->_error = 'searchd error: '.substr($response, 4);

            return false;
        }
        if ($status == SEARCHD_RETRY) {
            $this->_error = 'temporary searchd error: '.substr($response, 4);

            return false;
        }
        if ($status != SEARCHD_OK) {
            $this->_error = "unknown status code '$status'";

            return false;
        }

        // check version
        if ($ver < $client_ver) {
            $this->_warning = sprintf("searchd command v.%d.%d older than client's v.%d.%d, some options might not work",
                $ver >> 8, $ver & 0xff, $client_ver >> 8, $client_ver & 0xff);
        }

        return $response;
    }
483099
public static function skip_varint($fp)
    {
        $len = 0;
        do { // Keep reading until we find the last byte
            $b = fread($fp, 1);
            if ($b === false) {
                throw new Exception("skip(varint): Error reading byte");
            }
            $len++;
        } while ($b >= "\x80");

        return $len;
    }
210411
public function getFpn(): FilePathNormalizerInterface
    {
        if (null === $this->fpn) {
            $this->fpn = new FilePathNormalizer();
        }
        return $this->fpn;
    }
1119604
private function getStream(Version $fv)
    {
        try {
            return $fv->getFileResource()->readStream() ?: null;
        } catch (Exception $x) {
            return null;
        } catch (Throwable $x) {
            return null;
        }
    }
172081
public function file(string $name): string {
        if (!isset($this->file[$name])) {
            return "";
        }
        return $this->file[$name];
    }
846459
private function readId3v1Body($fp) {
        $this->tags1['song'] = trim(fread($fp, 30));
        $this->tags1['artist'] = trim(fread($fp, 30));
        $this->tags1['album'] = trim(fread($fp, 30));
        $this->tags1['year'] = trim(fread($fp, 4));
        $this->tags1['comment'] = trim(fread($fp, 28));
        fseek($fp, 1, SEEK_CUR);
        $this->tags1['track'] = ord(fread($fp, 1));
        $this->tags1['genre'] = ord(fread($fp, 1));
        return 128;
    }
191386
public function tryFileLoading($locator) {
		//file is actually a class name or namespace
		if (strrpos($locator, '.') === FALSE) {
			return $locator;
		}
		$className = $this->formatClassName($locator);
		if (class_exists($className)) {
			return $className;
		}

		$filesep = '/';
		$loaded = FALSE;

		foreach ($this->searchDirs as $_dir) {
			$file = $this->rootDir.$filesep.$_dir.$filesep.$locator;
			if(file_exists($file)) {
				if(include_once($file)) {
					$loaded = TRUE;
					break;
				}
			}
		}
		if (!$loaded) {
			return FALSE;
		}
		return $className;
	}
850768
def readfp(self, fp, filename=None):
        """"""
        warnings.warn(
            "This method will be removed in future versions.  "
            "Use 'parser.read_file()' instead.",
            DeprecationWarning, stacklevel=2
        )
        self.read_file(fp, source=filename)
587325
public function extractImageFromPdf($filePath, $page = 0)
    {
        $pathInfo = pathinfo($filePath);
        $extractedImagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR
            . time() . $pathInfo['basename'] . '-' . $page . '.jpg';

        $image = $this->imagickFactory->create($filePath);
        $image->setIteratorIndex($page);
        $image->writeImage($extractedImagePath);

        return $extractedImagePath;
    }
1011251
protected function getPhpFilesetFinder() {
    $finder = new Finder();
    $finder
      ->files()
      ->name("*.inc")
      ->name("*.install")
      ->name("*.module")
      ->name("*.php")
      ->name("*.profile")
      ->name("*.test")
      ->name("*.theme")
      // Behat php files are ignored because method names and comments do not
      // conform to Drupal coding standards by default.
      ->notPath('behat')
      ->notPath('node_modules')
      ->notPath('vendor');
    return $finder;
  }