@brief Loads an existing report in to a reportico class instance

@param $reportfile
@param string $projects_folder
@return Reportico
774224
static function &loadExistingReport($reportfile, $projects_folder = "projects")
    {
        $q = new Reportico();
        $q->reports_path = $projects_folder . "/" . ReporticoApp::getconfig("project");
        $q->projects_folder = $projects_folder;

        $reader = new XmlReader ($q, $reportfile, false);
        $reader->xml2query();

        return $q;
    }
73649
public function addReportModule(\CampaignChain\CoreBundle\Entity\ReportModule $reportModules)
    {
        $this->reportModules[] = $reportModules;

        return $this;
    }
158047
public function transform(ProjectDescriptor $project, Transformation $transformation)
    {
        $artifact = $this->getDestinationPath($transformation);

        $this->checkForSpacesInPath($artifact);

        $document = new \DOMDocument();
        $document->formatOutput = true;
        $report = $document->createElement('checkstyle');
        $report->setAttribute('version', '1.3.0');
        $document->appendChild($report);

        /** @var FileDescriptor $fileDescriptor */
        foreach ($project->getFiles()->getAll() as $fileDescriptor) {
            $file = $document->createElement('file');
            $file->setAttribute('name', $fileDescriptor->getPath());
            $report->appendChild($file);

            /** @var Error $error */
            foreach ($fileDescriptor->getAllErrors()->getAll() as $error) {
                $item = $document->createElement('error');
                $item->setAttribute('line', $error->getLine());
                $item->setAttribute('severity', $error->getSeverity());
                $item->setAttribute(
                    'message',
                    vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext())
                );
                $item->setAttribute('source', 'phpDocumentor.file.'.$error->getCode());
                $file->appendChild($item);
            }
        }

        $this->saveCheckstyleReport($artifact, $document);
    }
120465
public function mutateProjectFiles(Project $project)
    {
        /** @var ContentRendererFactory $contentRenderers */
        $contentRenderers = $project->get('content_renderers');

        foreach (array_keys($this->getFileList()) as $fileKey) {
            /** @var File $file */
            if (! $file = $project->get('files.'.$fileKey)) {
                continue;
            }

            $file->setData(['content_type' => $this->name]);

            if ($this->permalink !== '*') {
                $file->setPermalink(new Permalink($this->permalink));
            }

            // If we are not a default Content Type
            $templatePath = $project->sourceDirectory.DIRECTORY_SEPARATOR.'_views'.DIRECTORY_SEPARATOR.$this->template.'.phtml';
            if ($this->template !== 'default' && file_exists($templatePath)) {
                $fileRenderer = $contentRenderers->get($file->getExt());
                $file->setData(['content' => $fileRenderer->render($file)]);
                $file->setFileInfo(new SplFileInfo($templatePath, '_views', '_views'.DIRECTORY_SEPARATOR.$this->template.'.phtml'));

                if ($fileRenderer->supportsFrontMatter()) {
                    $frontMatter = new FrontMatter($file->getFileContent());
                    $file->setData(array_merge_recursive($file->getData(), $frontMatter->getData()));
                    $file->setContent($frontMatter->getContent());
                } else {
                    $file->setContent($file->getFileContent());
                }

                if ($file->hasData('generator')) {
                    $project->replaceFile($file, new FileGenerator($file));
                }
            }
        }
    }
1121710
public function loadProjects()
    {
        $this->showProgress('Loading projects and suites...', 'info');

        if (!is_arrayable($projects = $this->config('projects')) or count($projects) == 0) {
            $this->showProgress('No projects found.', 'error');

            return;
        }

        foreach ($projects as $data) {
            $this->showProgress("Project '{$data['name']}'", 'comment');

            $project = $this->dataRepository->createOrUpdateProject($data['name'], $data['path'], $data['tests_path']);

            $this->refreshProjectSuites($data, $project);

            $this->addToWatchFolders($data['path'], $data['watch_folders']);

            $this->addToExclusions($data['path'], $data['exclude']);
        }

        $this->dataRepository->deleteMissingProjects(collect($this->config('projects'))->pluck('name')->toArray());
    }
136745
public void loadProjectData( ProjectInfo currentSelectedProject, boolean zoomTo ) throws Exception {
        if (geopapDataLayer != null)
            geopapDataLayer.removeAllRenderables();

        Envelope bounds = new Envelope();

        File dbFile = currentSelectedProject.databaseFile;
        try (Connection connection = DriverManager.getConnection("jdbc:sqlite:" + dbFile.getAbsolutePath())) {

            // NOTES
            List<String[]> noteDataList = GeopaparazziUtilities.getNotesText(connection);
            StringBuilder sb = new StringBuilder();
            sb.append("\n\n// GP NOTES\n");
            int index = 0;
            PointPlacemarkAttributes notesAttributes = new PointPlacemarkAttributes();
            // notesAttributes.setLabelMaterial(mFillMaterial);
            // notesAttributes.setLineMaterial(mFillMaterial);
            // notesAttributes.setUsePointAsDefaultImage(true);
            notesAttributes.setImage(ImageCache.getInstance().getBufferedImage(ImageCache.NOTE));
            notesAttributes.setLabelMaterial(new Material(Color.BLACK));
            // notesAttributes.setScale(mMarkerSize);
            for( String[] noteData : noteDataList ) {
                // [lon, lat, altim, dateTimeString, text, descr]
                double lon = Double.parseDouble(noteData[0]);
                double lat = Double.parseDouble(noteData[1]);
                String altim = noteData[2];
                String date = noteData[3];
                String text = noteData[4];
                String descr = noteData[5];

                PointPlacemark marker = new PointPlacemark(Position.fromDegrees(lat, lon, 0));
                marker.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                marker.setLabelText(text + " (" + date + ")");
                marker.setAttributes(notesAttributes);

                if (geopapDataLayer != null)
                    geopapDataLayer.addRenderable(marker);

                bounds.expandToInclude(lon, lat);
            }

            /*
             * IMAGES
             */
            PointPlacemarkAttributes imageAttributes = new PointPlacemarkAttributes();
            imageAttributes.setImage(ImageCache.getInstance().getBufferedImage(ImageCache.DBIMAGE));
            imageAttributes.setLabelMaterial(new Material(Color.GRAY));
            for( org.hortonmachine.gears.io.geopaparazzi.geopap4.Image image : currentSelectedProject.images ) {
                double lon = image.getLon();
                double lat = image.getLat();

                PointPlacemark marker = new PointPlacemark(Position.fromDegrees(lat, lon, 0));
                marker.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
                marker.setLabelText(image.getName());
                marker.setAttributes(imageAttributes);

                if (geopapDataLayer != null)
                    geopapDataLayer.addRenderable(marker);
                bounds.expandToInclude(lon, lat);
            }

            try (Statement statement = connection.createStatement()) {
                statement.setQueryTimeout(30); // set timeout to 30 sec.

                String sql = "select " + //
                        GpsLogsTableFields.COLUMN_ID.getFieldName() + "," + //
                        GpsLogsTableFields.COLUMN_LOG_STARTTS.getFieldName() + "," + //
                        GpsLogsTableFields.COLUMN_LOG_ENDTS.getFieldName() + "," + //
                        GpsLogsTableFields.COLUMN_LOG_TEXT.getFieldName() + //
                        " from " + TABLE_GPSLOGS; //

                boolean useGpsElev = _useGpsElevationsCheckbox.isSelected();
                int altitudeMode = WorldWind.CLAMP_TO_GROUND;
                if (useGpsElev) {
                    altitudeMode = WorldWind.ABSOLUTE;
                }
                // first get the logs
                ResultSet rs = statement.executeQuery(sql);
                while( rs.next() ) {
                    long id = rs.getLong(1);

                    long startDateTime = rs.getLong(2);
                    String startDateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(startDateTime));
                    long endDateTime = rs.getLong(3);
                    String endDateTimeString = ETimeUtilities.INSTANCE.TIME_FORMATTER_LOCAL.format(new Date(endDateTime));
                    String text = rs.getString(4);

                    // points
                    String query = "select " //
                            + GpsLogsDataTableFields.COLUMN_DATA_LAT.getFieldName() + ","
                            + GpsLogsDataTableFields.COLUMN_DATA_LON.getFieldName() + ","
                            + GpsLogsDataTableFields.COLUMN_DATA_ALTIM.getFieldName() + ","
                            + GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName()//
                            + " from " + TABLE_GPSLOG_DATA + " where " + //
                            GpsLogsDataTableFields.COLUMN_LOGID.getFieldName() + " = " + id + " order by "
                            + GpsLogsDataTableFields.COLUMN_DATA_TS.getFieldName();

                    List<Position> verticesList = new ArrayList<>();
                    try (Statement newStatement = connection.createStatement()) {
                        newStatement.setQueryTimeout(30);
                        ResultSet result = newStatement.executeQuery(query);

                        while( result.next() ) {
                            double lat = result.getDouble(1);
                            double lon = result.getDouble(2);
                            double elev = 0.0;
                            if (useGpsElev)
                                elev = result.getDouble(3);
                            Position pos = Position.fromDegrees(lat, lon, elev);
                            verticesList.add(pos);
                            bounds.expandToInclude(lon, lat);
                        }
                    }

                    // color
                    String colorQuery = "select " //
                            + GpsLogsPropertiesTableFields.COLUMN_PROPERTIES_COLOR.getFieldName() + ","
                            + GpsLogsPropertiesTableFields.COLUMN_PROPERTIES_WIDTH.getFieldName() + " from "
                            + TABLE_GPSLOG_PROPERTIES + " where " + //
                            GpsLogsPropertiesTableFields.COLUMN_LOGID.getFieldName() + " = " + id;

                    String colorStr = RED_HEXA;
                    int lineWidth = 3;
                    try (Statement newStatement = connection.createStatement()) {
                        newStatement.setQueryTimeout(30);
                        ResultSet result = newStatement.executeQuery(colorQuery);

                        if (result.next()) {
                            colorStr = result.getString(1);
                            lineWidth = result.getInt(2);
                            if (colorStr.equalsIgnoreCase("red")) {
                                colorStr = RED_HEXA;
                            }
                        }
                        if (colorStr == null || colorStr.length() == 0) {
                            colorStr = RED_HEXA;
                        }
                    }

                    Color color = Color.RED;
                    try {
                        color = Color.decode(colorStr);
                    } catch (Exception e) {
                        // ignore Logger.INSTANCE.insertError("","Could not convert color: " +
                        // colorStr, e);
                    }

                    BasicShapeAttributes lineAttributes = new BasicShapeAttributes();
                    lineAttributes.setOutlineMaterial(new Material(color));
                    lineAttributes.setOutlineWidth(lineWidth);
                    Path path = new Path(verticesList);
                    path.setAltitudeMode(altitudeMode);
                    path.setFollowTerrain(true);
                    path.setAttributes(lineAttributes);

                    if (geopapDataLayer != null)
                        geopapDataLayer.addRenderable(path);
                }

            }

        }

        if (zoomTo) {
            bounds.expandBy(0.001);
            Sector sector = NwwUtilities.envelope2Sector(new ReferencedEnvelope(bounds, NwwUtilities.GPS_CRS));
            if (wwjPanel != null)
                wwjPanel.goTo(sector, false);
        }

        currentLoadedProject = currentSelectedProject;
    }
446153
public function makeReport()
    {
        $project = $this->element->project;
        $projectMetrics = $project->metrics;
        $coveredStatements = intval($projectMetrics['coveredstatements']);
        $statementsTotal = intval($projectMetrics['statements']);
        $reportTotal = round($this->safeDivision($coveredStatements, $statementsTotal) * 100);
        $fileReports = $this->makeFileReports($project);
        $report = new CoverageReport($reportTotal, $fileReports);
        return $report;
    }
987125
public ProjectFile read() throws MPXJException
   {
      try
      {
         m_project = new ProjectFile();
         m_eventManager = m_project.getEventManager();

         ProjectConfig config = m_project.getProjectConfig();
         config.setAutoTaskID(false);
         config.setAutoTaskUniqueID(false);
         config.setAutoResourceID(false);
         config.setAutoResourceUniqueID(false);
         config.setAutoOutlineLevel(false);
         config.setAutoOutlineNumber(false);
         config.setAutoWBS(false);
         config.setAutoCalendarUniqueID(false);
         config.setAutoAssignmentUniqueID(false);

         m_project.getProjectProperties().setFileApplication("Microsoft");
         m_project.getProjectProperties().setFileType("MPD");

         m_project.getEventManager().addProjectListeners(m_projectListeners);

         processProjectProperties();
         processCalendars();
         processResources();
         processResourceBaselines();
         processTasks();
         processTaskBaselines();
         processLinks();
         processAssignments();
         processAssignmentBaselines();
         processExtendedAttributes();
         processSubProjects();
         postProcessing();

         return (m_project);
      }

      catch (SQLException ex)
      {
         throw new MPXJException(MPXJException.READ_ERROR, ex);
      }

      finally
      {
         reset();

         if (m_allocatedConnection && m_connection != null)
         {
            try
            {
               m_connection.close();
            }

            catch (SQLException ex)
            {
               // silently ignore errors on close
            }

            m_connection = null;
         }
      }
   }
1142847
public function build( $projects, $meetings )
	{
		$tree		= new XML_DOM_Node( $this->title );
		$cal		= new XML_DOM_Node( "vcalendar" );
		$cal->addChild( new XML_DOM_Node( "version", "2.0" ) );
		foreach( $projects as $project )
		{
			$start		= strtotime( $project['start'] );
			$end		= strtotime( $project['end'] );
			$event		= new XML_DOM_Node( "vevent" );
			$start		= new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
			$end		= new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
			$summary	= new XML_DOM_Node( "summary", $project['name'] );
			$event->addChild( $start );
			$event->addChild( $end );
			$event->addChild( $summary );
			$cal->addChild( $event );
		}

		foreach( $meetings as $meeting )
		{
			$start		= strtotime( $meeting['start'] );
			$end		= strtotime( $meeting['end'] );
			$event		= new XML_DOM_Node( "vevent" );
			$start		= new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
			$end		= new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
			$summary	= new XML_DOM_Node( "summary", $meeting['name'] );
			$event->addChild( $start );
			$event->addChild( $end );
			$event->addChild( $summary );
			$cal->addChild( $event );
		}
		$tree->addChild( $cal );

		$builder	= new FS_File_iCal_Builder();
		$ical		= $builder->build( $tree );
		return $ical;
	}
15722
private function addBuildListeners(Project $project)
    {
        // Add the default listener
        $project->addBuildListener($this->createLogger());

        foreach ($this->listeners as $listenerClassname) {
            try {
                $clz = Phing::import($listenerClassname);
            } catch (Exception $e) {
                $msg = "Unable to instantiate specified listener "
                    . "class " . $listenerClassname . " : "
                    . $e->getMessage();
                throw new ConfigurationException($msg);
            }

            $listener = new $clz();

            if ($listener instanceof StreamRequiredBuildLogger) {
                throw new ConfigurationException("Unable to add " . $listenerClassname . " as a listener, since it requires explicit error/output streams. (You can specify it as a -logger.)");
            }
            $project->addBuildListener($listener);
        }
    }
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);

    }
1130669
public function createProjectFiles($project)
    {
        $needConfigure = $this->checkKernelFiles();

        /**
         * project.c.
         */
        $content = $this->backend->getTemplateFileContents('project.c');
        if (empty($content)) {
            throw new Exception("Template project.c doesn't exist");
        }

        $includes = '';
        $reqInitializers = '';
        $reqDestructors = '';
        $prqDestructors = '';
        $modInitializers = '';
        $modDestructors = '';
        $glbInitializers = '';
        $glbDestructors = '';
        $files = array_merge($this->files, $this->anonymousFiles);

        /*
         * Round 1. Calculate the dependency rank
         */
        $this->calculateDependencies($files);

        $classEntries = [];
        $classInits = [];

        $interfaceEntries = [];
        $interfaceInits = [];

        /*
         * Round 2. Generate the ZEPHIR_INIT calls according to the dependency rank
         */
        foreach ($files as $file) {
            /** @var \Zephir\Compiler\FileInterface $file */
            if (!$file->isExternal()) {
                $classDefinition = $file->getClassDefinition();
                if ($classDefinition) {
                    $dependencyRank = $classDefinition->getDependencyRank();
                    if ('class' == $classDefinition->getType()) {
                        if (!isset($classInits[$dependencyRank])) {
                            $classEntries[$dependencyRank] = [];
                            $classInits[$dependencyRank] = [];
                        }
                        $classEntries[$dependencyRank][] =
                            'zend_class_entry *'.$classDefinition->getClassEntry().';';
                        $classInits[$dependencyRank][] =
                            'ZEPHIR_INIT('.$classDefinition->getCNamespace().'_'.
                             $classDefinition->getName().');';
                    } else {
                        if (!isset($interfaceInits[$dependencyRank])) {
                            $interfaceEntries[$dependencyRank] = [];
                            $interfaceInits[$dependencyRank] = [];
                        }
                        $interfaceEntries[$dependencyRank][] =
                            'zend_class_entry *'.$classDefinition->getClassEntry().';';
                        $interfaceInits[$dependencyRank][] =
                            'ZEPHIR_INIT('.$classDefinition->getCNamespace().'_'.
                            $classDefinition->getName().');';
                    }
                }
            }
        }

        krsort($classInits);
        krsort($classEntries);
        krsort($interfaceInits);
        krsort($interfaceEntries);

        $completeInterfaceInits = [];
        foreach ($interfaceInits as $rankInterfaceInits) {
            asort($rankInterfaceInits, SORT_STRING);
            $completeInterfaceInits = array_merge($completeInterfaceInits, $rankInterfaceInits);
        }

        $completeInterfaceEntries = [];
        foreach ($interfaceEntries as $rankInterfaceEntries) {
            asort($rankInterfaceEntries, SORT_STRING);
            $completeInterfaceEntries = array_merge($completeInterfaceEntries, $rankInterfaceEntries);
        }

        $completeClassInits = [];
        foreach ($classInits as $rankClassInits) {
            asort($rankClassInits, SORT_STRING);
            $completeClassInits = array_merge($completeClassInits, $rankClassInits);
        }

        $completeClassEntries = [];
        foreach ($classEntries as $rankClassEntries) {
            asort($rankClassEntries, SORT_STRING);
            $completeClassEntries = array_merge($completeClassEntries, $rankClassEntries);
        }

        /*
         * Round 3. Process extension globals
         */
        list($globalCode, $globalStruct, $globalsDefault, $initEntries) = $this->processExtensionGlobals($project);
        if ('zend' == $project) {
            $safeProject = 'zend_';
        } else {
            $safeProject = $project;
        }

        /**
         * Round 4. Process extension info.
         */
        $phpInfo = $this->processExtensionInfo();

        /*
         * Round 5. Generate Function entries (FE)
         */
        list($feHeader, $feEntries) = $this->generateFunctionInformation();

        /**
         * Check if there are module/request/global destructors.
         */
        $destructors = $this->config->get('destructors');
        if (\is_array($destructors)) {
            $invokeRequestDestructors = $this->processCodeInjection($destructors, 'request');
            $includes .= PHP_EOL.$invokeRequestDestructors[0];
            $reqDestructors = $invokeRequestDestructors[1];

            $invokePostRequestDestructors = $this->processCodeInjection($destructors, 'post-request');
            $includes .= PHP_EOL.$invokePostRequestDestructors[0];
            $prqDestructors = $invokePostRequestDestructors[1];

            $invokeModuleDestructors = $this->processCodeInjection($destructors, 'module');
            $includes .= PHP_EOL.$invokeModuleDestructors[0];
            $modDestructors = $invokeModuleDestructors[1];

            $invokeGlobalsDestructors = $this->processCodeInjection($destructors, 'globals');
            $includes .= PHP_EOL.$invokeGlobalsDestructors[0];
            $glbDestructors = $invokeGlobalsDestructors[1];
        }

        /**
         * Check if there are module/request/global initializers.
         */
        $initializers = $this->config->get('initializers');
        if (\is_array($initializers)) {
            $invokeRequestInitializers = $this->processCodeInjection($initializers, 'request');
            $includes .= PHP_EOL.$invokeRequestInitializers[0];
            $reqInitializers = $invokeRequestInitializers[1];

            $invokeModuleInitializers = $this->processCodeInjection($initializers, 'module');
            $includes .= PHP_EOL.$invokeModuleInitializers[0];
            $modInitializers = $invokeModuleInitializers[1];

            $invokeGlobalsInitializers = $this->processCodeInjection($initializers, 'globals');
            $includes .= PHP_EOL.$invokeGlobalsInitializers[0];
            $glbInitializers = $invokeGlobalsInitializers[1];
        }

        /**
         * Append extra details.
         */
        $extraClasses = $this->config->get('extra-classes');
        if (\is_array($extraClasses)) {
            foreach ($extraClasses as $value) {
                if (isset($value['init'])) {
                    $completeClassInits[] = 'ZEPHIR_INIT('.$value['init'].')';
                }

                if (isset($value['entry'])) {
                    $completeClassEntries[] = 'zend_class_entry *'.$value['entry'].';';
                }
            }
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%PROJECT_CAMELIZE%' => ucfirst($project),
            '%CLASS_ENTRIES%' => implode(
                PHP_EOL,
                array_merge($completeInterfaceEntries, $completeClassEntries)
            ),
            '%CLASS_INITS%' => implode(
                PHP_EOL."\t",
                array_merge($completeInterfaceInits, $completeClassInits)
            ),
            '%INIT_GLOBALS%' => implode(
                PHP_EOL."\t",
                array_merge((array) $globalsDefault[0], [$glbInitializers])
            ),
            '%INIT_MODULE_GLOBALS%' => $globalsDefault[1],
            '%DESTROY_GLOBALS%' => $glbDestructors,
            '%EXTENSION_INFO%' => $phpInfo,
            '%EXTRA_INCLUDES%' => implode(
                PHP_EOL,
                array_unique(explode(PHP_EOL, $includes))
            ),
            '%MOD_INITIALIZERS%' => $modInitializers,
            '%MOD_DESTRUCTORS%' => $modDestructors,
            '%REQ_INITIALIZERS%' => implode(
                PHP_EOL."\t",
                array_merge($this->internalInitializers, [$reqInitializers])
            ),
            '%REQ_DESTRUCTORS%' => $reqDestructors,
            '%POSTREQ_DESTRUCTORS%' => empty($prqDestructors) ? '' : implode(
                PHP_EOL,
                [
                    '#define ZEPHIR_POST_REQUEST 1',
                    'static PHP_PRSHUTDOWN_FUNCTION('.strtolower($project).')',
                    '{',
                    "\t".implode(
                        PHP_EOL."\t",
                        explode(PHP_EOL, $prqDestructors)
                    ),
                    '}',
                ]
            ),
            '%FE_HEADER%' => $feHeader,
            '%FE_ENTRIES%' => $feEntries,
            '%PROJECT_INI_ENTRIES%' => implode(PHP_EOL."\t", $initEntries),
        ];
        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        /*
         * Round 5. Generate and place the entry point of the project
         */
        file_put_contents_ex($content, 'ext/'.$safeProject.'.c');
        unset($content);

        /**
         * Round 6. Generate the project main header.
         */
        $content = $this->backend->getTemplateFileContents('project.h');
        if (empty($content)) {
            throw new Exception("Template project.h doesn't exists");
        }

        $includeHeaders = [];
        foreach ($this->compiledFiles as $file) {
            if ($file) {
                $fileH = str_replace('.c', '.zep.h', $file);
                $include = '#include "'.$fileH.'"';
                $includeHeaders[] = $include;
            }
        }

        /**
         * Append extra headers.
         */
        $extraClasses = $this->config->get('extra-classes');
        if (\is_array($extraClasses)) {
            foreach ($extraClasses as $value) {
                if (isset($value['header'])) {
                    $include = '#include "'.$value['header'].'"';
                    $includeHeaders[] = $include;
                }
            }
        }

        $toReplace = [
            '%INCLUDE_HEADERS%' => implode(PHP_EOL, $includeHeaders),
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/'.$safeProject.'.h');
        unset($content);

        /**
         * Round 7. Create php_project.h.
         */
        $content = $this->backend->getTemplateFileContents('php_project.h');
        if (empty($content)) {
            throw new Exception("Template php_project.h doesn't exist");
        }

        $toReplace = [
            '%PROJECT_LOWER_SAFE%' => strtolower($safeProject),
            '%PROJECT_LOWER%' => strtolower($project),
            '%PROJECT_UPPER%' => strtoupper($project),
            '%PROJECT_EXTNAME%' => strtolower($project),
            '%PROJECT_NAME%' => utf8_decode($this->config->get('name')),
            '%PROJECT_AUTHOR%' => utf8_decode($this->config->get('author')),
            '%PROJECT_VERSION%' => utf8_decode($this->config->get('version')),
            '%PROJECT_DESCRIPTION%' => utf8_decode($this->config->get('description')),
            '%PROJECT_ZEPVERSION%' => Zephir::VERSION,
            '%EXTENSION_GLOBALS%' => $globalCode,
            '%EXTENSION_STRUCT_GLOBALS%' => $globalStruct,
        ];

        foreach ($toReplace as $mark => $replace) {
            $content = str_replace($mark, $replace, $content);
        }

        file_put_contents_ex($content, 'ext/php_'.$safeProject.'.h');
        unset($content);

        return $needConfigure;
    }
475982
public static function executeReportTask(ReportTask $reportTask, $action = 'store')
    {
        $parameters = [];
        if($reportTask->frequency_023 == 1) // one time
        {
            $parameters['from']    = $reportTask->from_023;
            $parameters['until']   = $reportTask->until_023;
        }

        // get data about frequency
        $frequency                  = self::getFrequencyData($reportTask->frequency_023, $parameters);

        // replace wildcards
        if(isset($frequency['from']))
            $reportTask->sql_023    = str_replace("#FROM#", $frequency['from'], $reportTask->sql_023);
        if(isset($frequency['until']))
            $reportTask->sql_023    = str_replace("#UNTIL#", $frequency['until'], $reportTask->sql_023);

        // Execute query from report task
        $objects = DB::connection('mysql2')->select(DB::raw($reportTask->sql_023));

        // if has results from query
        if(count($objects) == 0)
            return false;

        // *************************************************************
        // transform string data to number data, to operate with excel
        // *************************************************************
        foreach ($objects as &$object)
        {
            $fields = get_object_vars($object);
            foreach ($fields as $key => $value)
            {
                if(is_numeric($value) && strpos($value, '.') === false)
                {
                    $object->{$key} = (int) $value;
                }
                elseif(is_numeric($value) && strpos($value, '.') !== false)
                {
                    $object->{$key} = (float) $value;
                }
            }
        }

        // format response to manage with collections
        $objects = collect(array_map(function($item) {
            return collect($item);
        }, $objects));

        // ***************************
        // get sum columns from numerics fields
        // ***************************
        $object         = $objects->first();
        $operationsRow  = [];
        $object->map(function ($item, $key) use (&$operationsRow, $objects) {
            if(is_numeric($item))
            {
                try
                {
                    $operationsRow[$key] = $objects->sum($key);
                }
                catch (\Exception $e)
                {
                    Log::error($e->getMessage());
                }
            }
            else
            {
                $operationsRow[$key] = null;
            }
        });

        $filename = $reportTask->filename_023 . '-' . uniqid();

        // create spreadsheet to export data
        $excel = Excel::create($filename, function($excel) use ($objects, $operationsRow) {

            // set the title
            $excel->setTitle('Report')
                ->setCreator('Pulsar')
                ->setCompany('SYSCOVER');

            // set sheet
            $excel->sheet('Data', function ($sheet) use ($objects, $operationsRow) {

                // get keys from first element
                $headers = $objects->first()->keys()->toArray();

                // set data and headers
                $sheet->prependRow($headers);
                $sheet->fromArray($objects->toArray(), null, 'A2', true, false);
                $sheet->cells('A1:' . $sheet->row(0)->getHighestDataColumn() . '1', function ($cells) {
                    $cells->setBackground('#CCCCCC');
                    $cells->setFontWeight('bold');
                });

                // append row with sum numeric columns
                if(count($operationsRow) > 0)
                {
                    $sheet->appendRow($operationsRow);
                    $sheet->cells('A' . $sheet->row(0)->getHighestRow() . ':' . $sheet->row(0)->getHighestDataColumn() . $sheet->row(0)->getHighestRow(), function ($cells) {
                        $cells->setBackground('#F8F8F8');
                        $cells->setFontWeight('bold');
                    });
                }
            });
        });

        // get excel option
        if($action == 'store')
        {
            $excel->store($reportTask->extension_file_023);

            // transform json to array and get ccEmails object
            $ccEmailsJson   = json_decode($reportTask->cc_023);
            $ccEmails       = [];
            if(is_array($ccEmailsJson) && count($ccEmailsJson) > 0)
            {
                foreach($ccEmailsJson as $ccEmail)
                {
                    $ccEmails[] = $ccEmail->label;
                }
            }

            // delivery reports
            $dataMessage = [
                'emailTo'           => $reportTask->email_023,
                'cc'                => $ccEmails,
                'subject'           => $reportTask->subject_023,
                'token'             => Crypt::encrypt($reportTask->id_023),
                'filename'          => Crypt::encrypt($filename),
                'reportTask'        => $reportTask
            ];

            Mail::send('pulsar::emails.report_task_notification', $dataMessage, function($m) use ($dataMessage) {
                $m->to($dataMessage['emailTo'])
                    ->subject($dataMessage['subject']);

                // send copy to alternative emails
                foreach ($dataMessage['cc'] as $cc)
                    $m->cc($cc);
            });
        }
        else
        {
            $excel->download($reportTask->extension_file_023);
        }

        // updates time stamp of executions
        ReportTask::where('id_023', $reportTask->id_023)->update([
            'last_run_023' => $frequency['lastRun'],
            'next_run_023' => $frequency['nextRun']
        ]);

        return true;
    }
131764
public function execute(ProjectDescriptor $project): void
    {
        $markerTerms = $project->getSettings()->getMarkers();

        foreach ($project->getFiles() as $file) {
            $marker_data = [];
            $matches = [];
            preg_match_all(
                '~//[\s]*(' . implode('|', $markerTerms) . ')\:?[\s]*(.*)~',
                $file->getSource(),
                $matches,
                PREG_SET_ORDER | PREG_OFFSET_CAPTURE
            );

            foreach ($matches as $match) {
                list($before) = str_split($file->getSource(), $match[1][1]); // fetches all the text before the match

                $line_number = strlen($before) - strlen(str_replace("\n", '', $before)) + 1;

                $marker_data[] = ['type' => trim($match[1][0], '@'), 'line' => $line_number, $match[2][0]];
            }

            $file->setMarkers(new Collection($marker_data));
        }
    }
1336655
private ProjectFile readProjectFile(ProjectReader reader, File file) throws MPXJException
   {
      addListeners(reader);
      return reader.read(file);
   }
995691
@Override
    protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
        // Need to refresh? -- CahcedReport should be made abstract and the type should define which class to use
        // and what refresh checking method is used.
        if (!cache.containsKey(reportId) || cache.get(reportId).getLastModified() != report.lastModified())
        {
            super.loadReport(result, report, reportId);
            cache.put(reportId,new CachedReport(result.getReports().get(reportId),report.lastModified()));
        }
        result.getReports().put(reportId, cache.get(reportId).getReportConfig());
    }
661469
def __load_project_from_file_path(file_path):
    '''
    
    '''
    try:
        project = get_project(project_dir=os.path.dirname(file_path),
                              config_path=[os.path.basename(file_path)])
    except Exception as inst:
        return __handle_except(inst)
    return project