Export the files in the given file area in a list.

@param string $filearea
@return string HTML
503617
protected function export_files_list($filearea) {

        $output = '';
        $files = [];

        foreach ($this->multifiles as $file) {
            if ($file->is_directory()) {
                continue;
            }
            if ($file->get_filearea() !== $filearea) {
                continue;
            }
            if ($file->is_valid_image()) {
                // Not optimal but looks better than original images.
                $files[] = html_writer::tag('li', $this->exporter->get('format')->file_output($file,
                    ['attributes' => ['style' => 'max-height:24px; max-width:24px']]).' '.s($file->get_filename()));
            } else {
                $files[] = html_writer::tag('li', $this->exporter->get('format')->file_output($file));
            }
        }

        if ($files) {
            $output .= html_writer::tag('ul', implode('', $files));
        }

        return $output;
    }
486444
public function column_file( $item ) {
		$html = '<div class="export-file">';
		$html .= $this->getIcon( $item['file'] );
		$html .= '<div class="export-file-name">' . esc_html( $item['file'] ) . '</div>';
		$html .= '</div>';

		$delete_url = sprintf( '/admin.php?page=%s&action=%s&ID=%s', $_REQUEST['page'], 'delete', $item['ID'] );
		$delete_url = get_admin_url( get_current_blog_id(), $delete_url );
		$delete_url = esc_url( add_query_arg( '_wpnonce', wp_create_nonce( 'bulk-files' ), $delete_url ) );
		$onclick = 'onclick="if ( !confirm(\'' . esc_attr( __( 'Are you sure you want to delete this export file?', 'pressbooks' ) ) . '\') ) { return false }"';
		$actions['delete'] = sprintf(
			'<a href="%s" aria-label="%s" ' . $onclick . '>%s</a>',
			$delete_url,
			/* translators: %s: file */
			esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $item['file'] ) ),
			_x( 'Delete', 'verb' )
		);

		$download_url = get_admin_url( get_current_blog_id(), "/admin.php?page=pb_export&download_export_file={$item['file']}" );
		$actions['download'] = sprintf(
			'<a href="%s" aria-label="%s" >%s</a>',
			$download_url,
			/* translators: %s: file */
			esc_attr( sprintf( __( 'Download &#8220;%s&#8221;' ), $item['file'] ) ),
			_x( 'Download', 'verb' )
		);

		$html .= $this->row_actions( $actions );

		return $html;
	}
1002431
protected function export()
    {
        $filesystem = new Filesystem();
        $handle = fopen($this->config['path'] . $this->prefix, "w");

        $checkPermissions = true;
        if (PHP_SAPI == 'cli') {
            $checkPermissions = false;
        }

        if (!$this->export->Init(
            $handle,
            $this->config["id"],
            false,
            true,
            $this->session["work_dir"],
            $this->session["file_dir"],
            $checkPermissions
        )
        ) {
            throw new ExportException('Failed to initialize export');
        }

        $this->export->DoNotDownloadCloudFiles();
        $this->export->StartExport();

        $this->export->StartExportMetadata();
        $this->export->ExportProperties($this->session["property_map"]);
        $this->export->ExportSections(
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            $this->config["sections"],
            $this->session["property_map"]
        );
        $this->export->EndExportMetadata();

        $this->export->StartExportCatalog();
        $this->export->ExportElements(
            $this->session["property_map"],
            $this->session["section_map"],
            time(),
            $this->config['interval'],
            0,
            $this->config["elements"]
        );
        $this->export->EndExportCatalog();

        $this->export->ExportProductSets();
        $this->export->EndExport();

        fclose($handle);
        $filesystem->remove($this->config['path']);
        $filesystem->rename($this->config['path'] . $this->prefix, $this->config['path'], true);
    }
840558
public function exportAction()
	{
		$cntl = $this->createAdmin();

		if( ( $html = $cntl->export() ) == '' ) {
			return $this->setPsrResponse( $cntl->getView()->response() );
		}

		$this->view->assign( 'content', $html );
	}
845864
protected function generateTextarea($options, $currentValue = null)
    {
        $value = is_null($currentValue) ? $options['value'] : $currentValue;

        unset($options['value']);
        unset($options["type"]);

        return sprintf('<textarea %s>%s</textarea>', $this->arrayToHtmlAttributes($options), stripslashes($value));
    }
1095856
protected function to_document(\core_search\base $searcharea, $docdata) {

        list($componentname, $areaname) = \core_search\manager::extract_areaid_parts($docdata['areaid']);
        $doc = \core_search\document_factory::instance($docdata['itemid'], $componentname, $areaname, $this);
        $doc->set_data_from_engine($docdata);
        $doc->set_doc_url($searcharea->get_doc_url($doc));
        $doc->set_context_url($searcharea->get_context_url($doc));
        $doc->set_doc_icon($searcharea->get_doc_icon($doc));

        // Uses the internal caches to get required data needed to render the document later.
        $course = $this->get_course($doc->get('courseid'));
        $doc->set_extra('coursefullname', $course->fullname);

        if ($doc->is_set('userid')) {
            $user = $this->get_user($doc->get('userid'));
            $doc->set_extra('userfullname', fullname($user));
        }

        return $doc;
    }
1370113
protected function dumpAssets($files, $targetFilename = null, $useRequireJs = false)
    {
        $content = '';
        foreach ($files as $file) {
            $content .= file_get_contents($file) . "\n";
        }
        if ($useRequireJs) {
            $content = "define('debugbar', ['jquery'], function($){\r\n" . $content . "\r\n return PhpDebugBar; \r\n});";
        }
        if ($targetFilename !== null) {
            file_put_contents($targetFilename, $content);
        } else {
            echo $content;
        }
    }
1185330
public function textArea(TextArea $textArea)
    {
        $value = htmlentities($textArea->getValue(), ENT_QUOTES, 'UTF-8');

        $tag = new Tag('textarea', $value);
        $tag->setAttribute('cols', $textArea->getCols());
        $tag->setAttribute('rows', $textArea->getRows());

        return $this->parseTag($tag, $textArea);
    }
1039957
private function copy_feedback_files(context $context, string $filearea, int $itemid) {
        if ($this->feedbackfiles) {
            $filestocopycontextid = $this->feedbackfiles['contextid'];
            $filestocopycomponent = $this->feedbackfiles['component'];
            $filestocopyfilearea = $this->feedbackfiles['filearea'];
            $filestocopyitemid = $this->feedbackfiles['itemid'];

            $fs = new file_storage();
            if ($filestocopy = $fs->get_area_files($filestocopycontextid, $filestocopycomponent, $filestocopyfilearea,
                    $filestocopyitemid)) {
                foreach ($filestocopy as $filetocopy) {
                    $destination = [
                        'contextid' => $context->id,
                        'component' => GRADE_FILE_COMPONENT,
                        'filearea' => $filearea,
                        'itemid' => $itemid
                    ];
                    $fs->create_file_from_storedfile($destination, $filetocopy);
                }
            }
        }
    }
1293048
function ReportAreaAction(Area $area, Enums\Action $action)
    {
        $logItem = $this->CreateLogItem(Enums\ObjectType::Area(), $action);       
        if (!$action->Equals(Enums\Action::Delete()))
        {
            $logArea = new LogArea();
            $logArea->SetLogItem($logItem);
            $logArea->SetArea($area);
            $logArea->Save();
        }
        else
        {
            $this->ReportLayoutAction($area->GetLayout(), Enums\Action::ChildDelete());
        }
    }
373501
public static function exportToFile(
        string $file,
        OutputInterface $output,
        callable $queryItems
    ) {
        $resource = fopen($file, 'w');

        $i = 1;
        $count = 0;
        while (true) {
            $items = $queryItems(Query::create('', $i, 500))->getItems();

            if (empty($items)) {
                break;
            }

            self::writeItemsToResource(
                $resource,
                $items
            );
            self::printPartialCountSaved($output, count($items));

            $count += count($items);
            ++$i;
        }

        fclose($resource);

        return $count;
    }
1057639
protected static function export_used_files($context, $subwikiid, $alltexts) {
        if (!self::text_has_files($alltexts)) {
            return;
        }
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_wiki', 'attachments', $subwikiid,
            'filepath, filename', false);
        if (empty($files)) {
            return;
        }
        usort($files, function($file1, $file2) {
            return strcmp($file2->get_filepath(), $file1->get_filename());
        });
        foreach ($files as $file) {
            $filepath = $file->get_filepath() . $file->get_filename();
            $needles = ['@@PLUGINFILE@@' . s($filepath),
                '@@PLUGINFILE@@' . $filepath,
                '@@PLUGINFILE@@' . str_replace(' ', '%20', $filepath),
                '@@PLUGINFILE@@' . s($filepath),
                '@@PLUGINFILE@@' . s(str_replace(' ', '%20', $filepath))
            ];
            $needles = array_unique($needles);
            $newtext = str_replace($needles, '', $alltexts);
            if ($newtext !== $alltexts) {
                $alltexts = $newtext;
                writer::with_context($context)->export_file([$subwikiid], $file);
                if (!self::text_has_files($alltexts)) {
                    return;
                }
            }
        }
    }
691551
protected function exportFieldData(array $data)
    {
        $replacements = array("\n" => '\\n', "\r" => '\\r', "\t" => '\\t');

        foreach ($data as &$item) {
            $item = strtr((string) $item, $replacements);
        }
        fwrite($this->_file, implode("\t", $data) . "\r\n");
    }
478376
public function get_files(stdClass $submission, stdClass $user) {
        $result = array();
        $fs = get_file_storage();

        $files = $fs->get_area_files($this->assignment->get_context()->id,
                                     'assignsubmission_file',
                                     ASSIGNSUBMISSION_FILE_FILEAREA,
                                     $submission->id,
                                     'timemodified',
                                     false);

        foreach ($files as $file) {
            // Do we return the full folder path or just the file name?
            if (isset($submission->exportfullpath) && $submission->exportfullpath == false) {
                $result[$file->get_filename()] = $file;
            } else {
                $result[$file->get_filepath().$file->get_filename()] = $file;
            }
        }
        return $result;
    }
23375
public function export($filename, $rows)
    {
        $delimiter     = $this->config->getDelimiter();
        $enclosure     = $this->config->getEnclosure();
        $enclosure     = empty($enclosure) ? "\0" : $enclosure;
        $newline       = $this->config->getNewline();
        $fromCharset   = $this->config->getFromCharset();
        $toCharset     = $this->config->getToCharset();
        $fileMode      = $this->config->getFileMode();
        $columnHeaders = $this->config->getColumnHeaders();

        try {
            $csv = new CsvFileObject($filename, $fileMode);
        } catch ( \Exception $e ) {
            throw new IOException($e->getMessage(), null, $e);
        }

        $csv->setNewline($newline);

        if ( $toCharset ) {
            $csv->setCsvFilter(function($line) use($toCharset, $fromCharset) {
                return mb_convert_encoding($line, $toCharset, $fromCharset);
            });
        }

        if (count($columnHeaders) > 0) {
            $this->checkRowConsistency($columnHeaders);
            $csv->fputcsv($columnHeaders, $delimiter, $enclosure);
        }

        foreach ( $rows as $row ) {
            $this->checkRowConsistency($row);
            $csv->fputcsv($row, $delimiter, $enclosure);
        }
        $csv->fflush();
    }
598898
public function export($p, $page)
    {
        $area = $p->addChild('area');
        $area->addAttribute('name', $this->getAreaHandle());
        $blocks = $page->getBlocks($this->getAreaHandle());
        $c = $this->getAreaCollectionObject();
        $style = $c->getAreaCustomStyle($this);
        if (is_object($style)) {
            $set = $style->getStyleSet();
            $set->export($area);
        }
        $wrapper = $area->addChild('blocks');
        foreach ($blocks as $bl) {
            $bl->export($wrapper);
        }
    }
320552
public function get_file_list($search = '') {
        global $CFG, $OUTPUT;
        $url = self::DOCUMENTFEED_URL;

        if ($search) {
            $url.='?q='.urlencode($search);
        }

        $files = array();
        $content = $this->googleoauth->get($url);
        try {
            if (strpos($content, '<?xml') !== 0) {
                throw new moodle_exception('invalidxmlresponse');
            }
            $xml = new SimpleXMLElement($content);
        } catch (Exception $e) {
            // An error occured while trying to parse the XML, let's just return nothing. SimpleXML does not
            // return a more specific Exception, that's why the global Exception class is caught here.
            return $files;
        }
        date_default_timezone_set(core_date::get_user_timezone());
        foreach ($xml->entry as $gdoc) {
            $docid  = (string) $gdoc->children('http://schemas.google.com/g/2005')->resourceId;
            list($type, $docid) = explode(':', $docid);

            $title  = '';
            $source = '';
            // FIXME: We're making hard-coded choices about format here.
            // If the repo api can support it, we could let the user
            // chose.
            switch($type){
                case 'document':
                    $title = $gdoc->title.'.rtf';
                    $source = 'https://docs.google.com/feeds/download/documents/Export?id='.$docid.'&exportFormat=rtf';
                    break;
                case 'presentation':
                    $title = $gdoc->title.'.ppt';
                    $source = 'https://docs.google.com/feeds/download/presentations/Export?id='.$docid.'&exportFormat=ppt';
                    break;
                case 'spreadsheet':
                    $title = $gdoc->title.'.xls';
                    $source = 'https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key='.$docid.'&exportFormat=xls';
                    break;
                case 'pdf':
                case 'file':
                    $title  = (string)$gdoc->title;
                    // Some files don't have a content probably because the download has been restricted.
                    if (isset($gdoc->content)) {
                        $source = (string)$gdoc->content[0]->attributes()->src;
                    }
                    break;
            }

            $files[] =  array( 'title' => $title,
                'url' => "{$gdoc->link[0]->attributes()->href}",
                'source' => $source,
                'date'   => strtotime($gdoc->updated),
                'thumbnail' => (string) $OUTPUT->image_url(file_extension_icon($title, 32))
            );
        }
        core_date::set_default_server_timezone();

        return $files;
    }