@param string     $filename
@param FileReport $report

@return bool|string
514713
private function getSchemaValidationSource($filename, $report)
    {
        if ((0 === preg_match('/^(http|https|ftp):/i', $filename))) {
            if (false === file_exists($filename)) {
                $filename = $report->getFile()->getPath() . '/' . $filename;
            }
            if (!is_readable($filename)) {
                $report->reportProblem('unable to validate, schema file is not readable: ' . $filename);

                return false;
            }
        }

        if (isset($this->cache[$filename])) {
            return $this->cache[$filename];
        }

        $validationSource = @file_get_contents($filename);

        if (false === $validationSource) {
            $report->reportProblem('unable to load schema file from: ' . $filename);

            return false;
        }

        if (empty($validationSource)) {
            $report->reportProblem(sprintf('xsd validation file is empty ("%s").', $filename));

            return false;
        }

        return $this->cache[$filename] = $validationSource;
    }
434915
public static function output($filename='excel', $format='Xlsx')
    {
        $objPhpSpreadsheet = self::validExcelObj();

        // Create Writer first
        $objWriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($objPhpSpreadsheet, $format);

        /**
         * Type Mapping
         */
        $inTypeList = isset(self::$_writerTypeInfo[$format]) ? true : false;
        $extension = ($inTypeList) ? self::$_writerTypeInfo[$format]['extension'] : '';
        $contentType = ($inTypeList) 
            ? self::$_writerTypeInfo[$format]['contentType'] 
            : 'application/octet-stream';

        // Redirect output to a client's web browser
        header("Content-Type: {$contentType}");
        /**
         * @see http://www.rfc-editor.org/rfc/rfc5987.txt
         */
        $filename = rawurlencode($filename);
        header("Content-Disposition: attachment; filename={$filename}{$extension}; filename*=UTF-8''{$filename}{$extension};");
        header("Cache-Control: max-age=0");

        $objWriter->save('php://output');
        exit;
    }
588230
protected function getFileModifiedTimestampOfFile($fileName, $format = 'Y-m-d H:i:s', $resultInUtc = false)
    {
        if (!file_exists($fileName)) {
            return ['error' => $fileName . ' was not found'];
        }
        $info = new \SplFileInfo($fileName);
        if ($format === 'PHPtime') {
            return $info->getMTime();
        }
        $sReturn = date($format, $info->getMTime());
        if ($resultInUtc) {
            $sReturn = gmdate($format, $info->getMTime());
        }
        return $sReturn;
    }
1346109
public function getFile($fileName)
    {
        $result = false;

        if (isset($_FILES[$fileName])) {
            $result = $_FILES[$fileName];
        }

        return $result;
    }
546254
public function getFile($reportId, $reportFragment, $optParams = array())
  {
    $params = array('reportId' => $reportId, 'reportFragment' => $reportFragment);
    $params = array_merge($params, $optParams);
    return $this->call('getFile', array($params));
  }
1313622
def write_report(filename)
      extension = File.extname(filename)
      report = yield(extension)
      File.open(filename, "wb") do |file|
        file.write(report)
      end
    end
380685
public function export_to_file($filename, $include_headers = true)
    {
        $fh = fopen($filename, 'w');
        if (false === $fh) {
            return false;
        }
        $export = $this->export($include_headers);
        $res = fwrite($fh, $export);
        if (false === $res) {
            return false;
        }

        return fclose($fh);
    }
300491
private function request(ReportRequest $reportRequest, array $options = [])
    {
        $reportDefinition = $reportRequest->getDefinition();

        if (empty($reportDefinition)) {
            throw new ReportDefinitionException(sprintf(
                'The report definition cannot be empty. Was expected XML document. You can build it with builder %s.',
                ReportDefinitionBuilder::class
            ));
        }

        $request = new Request(
            'POST',
            $this->user->resolveWsdl(self::ENDPOINT),
            $this->buildRequestHeaders($reportRequest),
            $reportDefinition
        );
        $invoker = $this->user->getInvoker();

        return $invoker(function () use ($request, $options, $reportRequest) {
            $this->lastRequest = $request;

            $event = new PreCallEvent('Reports:request', [$reportRequest], $this->user);
            $this->dispatcher->dispatch(Events::BEFORE_REQUEST, $event);

            $response = $this->httpClient->send($request, $options + [
                RequestOptions::HTTP_ERRORS => false,
            ]);
            $this->lastResponse = $response;

            if ($response->getStatusCode() >= 200 && $response->getStatusCode() <= 202) {
                $event = new PostCallEvent(
                    'Reports:request',
                    [$reportRequest],
                    $this->user,
                    $this,
                    $response->getBody()
                );
                $this->dispatcher->dispatch(Events::AFTER_REQUEST, $event);

                return $response;
            }

            $exception = $this->createException($response);

            $event = new FailCallEvent('Reports:request', [$reportRequest], $this->user, $this, $exception);
            $this->dispatcher->dispatch(Events::FAIL_REQUEST, $event);

            throw $exception;
        });
    }
1364063
static function &translateReportDesc($in_report)
    {
        $in_report = preg_replace("/\.xml$/", "", $in_report);
        $out_string = false;
        
        $langage = ReporticoApp::getConfig("language");
        $report_desc = ReporticoApp::get("report_desc");
        
        
        if ($report_desc) {
            if (array_key_exists($langage, $report_desc)) {
                $langset = &$report_desc[$langage];
                if (isset($langset[$in_report])) {
                    $out_string = &$langset[$in_report];
                }
            }
        }

        return $out_string;
    }
1192037
public function writeFile($filename)
    {

        if (!$filename) {
            trigger_error(ReporticoLang::templateXlate("UNABLE_TO_SAVE") . templateXlate("SPECIFYXML"), E_USER_ERROR);
            return false;
        }

        if (!preg_match("/\.xml$/", $filename)) {
            $filename = $filename . ".xml";
        }

        $projdir = $this->query->projects_folder . "/" . ReporticoApp::getConfig("project");
        if (!is_file($projdir)) {
            ReporticoUtility::findFileToInclude($projdir, $projdir);
        }

        if ($projdir && is_dir($projdir)) {

            $fn = $projdir . "/" . $filename;
            if (!($fd = @fopen($fn, "w"))) {

                trigger_error("Unable to open project file " . $fn . " for writing. Check folder and file permissions " , E_USER_ERROR);
                return false;
            }
        } else {


            trigger_error("Unable to open project area " . ReporticoApp::getConfig("project") . " to save file $filename " .
                $this->query->reports_path . "/" . $filename . " Not Found", E_USER_ERROR);
        }

        if (!fwrite($fd, '<?xml version="' . $this->xml_version . '"?>')) {
            return false;
        }

        $xmltext = $this->xmldata->unserialize();
        if (!fwrite($fd, $xmltext)) {
            return false;
        }

        fclose($fd);

    }
1235915
protected function returnReport(common_report_Report $report)
    {
        $data = $report->getData();
        $successes = $report->getSuccesses();

        // if report has no data, try to get it from the sub report
        while ($data === null && count($successes) > 0) {
            $firstSubReport = current($successes);
            $data = $firstSubReport->getData();
            $successes = $firstSubReport->getSuccesses();
        }

        if ($data !== null && $data instanceof core_kernel_classes_Resource) {
            $this->setData('selectNode', tao_helpers_Uri::encode($data->getUri()));
        }
        $this->setData('report', $report);
        $this->setView('report.tpl', 'tao');
    }
20354
public function addressbookMultiGetReport($report)
    {
        $contentType = $report->contentType;
        $version = $report->version;
        if ($version) {
            $contentType .= '; version='.$version;
        }

        $vcardType = $this->negotiateVCard(
            $contentType
        );

        $propertyList = [];
        $paths = array_map(
            [$this->server, 'calculateUri'],
            $report->hrefs
        );
        foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $props) {
            if (isset($props['200']['{'.self::NS_CARDDAV.'}address-data'])) {
                $props['200']['{'.self::NS_CARDDAV.'}address-data'] = $this->convertVCard(
                    $props[200]['{'.self::NS_CARDDAV.'}address-data'],
                    $vcardType
                );
            }
            $propertyList[] = $props;
        }

        $prefer = $this->server->getHTTPPrefer();

        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
        $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
    }
990855
public function addReport($report)
    {
        $report = (array) $report;

        foreach ($report as $r) {
            if (!preg_match('/^{([^}]*)}(.*)$/', $r)) {
                throw new DAV\Exception('Reportname must be in clark-notation');
            }
            $this->reports[] = $r;
        }
    }
376882
public function renderReport(Report $report)
    {
        $this->output->writeln('');

        $groupByFile = [];
        /** @var RuleViolation $violation */
        foreach ($report->getRuleViolations() as $violation) {
            $groupByFile[$violation->getFileName()][] = $violation;
        }

        /** @var ProcessingError $error */
        foreach ($report->getErrors() as $error) {
            $groupByFile[$error->getFile()][] = $error;
        }
        foreach ($groupByFile as $file => $problems) {
            $violationCount = 0;
            $errorCount     = 0;

            $table = new Table($this->output);
            $table->setStyle('borderless');
            foreach ($problems as $problem) {
                if ($problem instanceof RuleViolation) {
                    $table->addRow([$problem->getBeginLine(), '<comment>VIOLATION</comment>', $problem->getDescription()]);
                    ++$violationCount;
                }
                if ($problem instanceof ProcessingError) {
                    $table->addRow(['-', '<error>ERROR</error>', $problem->getMessage()]);
                    ++$errorCount;
                }
            }

            $this->output->writeln([
                sprintf('<fg=white;options=bold>FILE: %s</>', str_replace($this->basePath.'/', '', $file)),
                sprintf('<fg=white;options=bold>FOUND %d ERRORS AND %d VIOLATIONS</>', $errorCount, $violationCount),
            ]);
            $table->render();
            $this->output->writeln('');
        }
    }
866485
public static Report restoreSubreportsInMaster(Report report) {
        JasperContent reportContent = (JasperContent) report.getContent();
        List<JcrFile> subreportFiles = reportContent.getSubreports();
		if (subreportFiles.size() > 0) {
			JcrFile masterFile = reportContent.getMaster();
			try {
				String masterContent = new String(masterFile.getDataProvider().getBytes(), "UTF-8");
				List<String> subreportsContent = new ArrayList<String>();
				for (int i = 0, size = subreportFiles.size(); i < size; i++) {
					subreportsContent.add(new String(subreportFiles.get(i).getDataProvider().getBytes(), "UTF-8"));
				}
				for (int i = 0, size = subreportFiles.size(); i < size; i++) {
					String name = subreportFiles.get(i).getName();
					String oldName = getUnique(name, report.getId()) + "." + JASPER_COMPILED_EXT;
					String newName = name + "." + JASPER_COMPILED_EXT;
					masterContent = masterContent.replaceAll(oldName, newName);
					for (int j = 0; j < size; j++) {
						if (j != i) {
							subreportsContent.set(j, subreportsContent.get(j).replaceAll(oldName, newName));
						}
					}
					if (LOG.isDebugEnabled()) {
						LOG.debug("Subreport " + name + ": " + oldName + " > " + newName);
						// LOG.debug("master = " + master);
					}
				}
				masterFile.setDataProvider(new JcrDataProviderImpl(masterContent.getBytes("UTF-8")));
				for (int i = 0, size = subreportFiles.size(); i < size; i++) {
					subreportFiles.get(i).setDataProvider(new JcrDataProviderImpl(subreportsContent.get(i).getBytes("UTF-8")));
				}
			} catch (UnsupportedEncodingException e) {
				LOG.error("Error inside JasperUtil.restoreSubreportsInMaster: " + e.getMessage(), e);
				e.printStackTrace();
			}
		}

        return report;
    }
988104
public function notify(Report $report, callable $callback = null)
    {
        $this->pipeline->execute($report, function ($report) use ($callback) {
            if ($callback) {
                $resolvedReport = null;

                $bridge = new CallbackBridge($callback);
                $bridge($report, function ($report) use (&$resolvedReport) {
                    $resolvedReport = $report;
                });
                if ($resolvedReport) {
                    $report = $resolvedReport;
                } else {
                    return;
                }
            }

            $this->http->queue($report);
        });

        $this->leaveBreadcrumb($report->getName(), Breadcrumb::ERROR_TYPE, $report->getSummary());

        if (!$this->config->isBatchSending()) {
            $this->flush();
        }
    }
194521
public function write($file_name, $content = '')
    {
        if (!is_file($file_name)) {
            return false;
        }

        return file_put_contents($file_name, $content, LOCK_EX);
    }