Generate the info column.

@param \stdClass $log log data.
@return string HTML for the score column
557910
public function col_info($log) {
        global $PAGE;

        if (empty($log->info) && empty($log->dir)) {
            return '';
        }

        $info = array();
        if (!empty($log->info)) {
            $info = json_decode($log->info);
        }
        if (!empty($log->dir)) {
            $info[] = get_string('predictorresultsin', 'tool_analytics', $log->dir);
        }
        $PAGE->requires->js_call_amd('tool_analytics/log_info', 'loadInfo', array($log->id, $info));
        return \html_writer::link('#', get_string('view'), array('data-model-log-id' => $log->id));
    }
302374
public function ProcessEvaluationResult( $log )
	{
		global $debug_statements;

		if ( $debug_statements )
		{
			\XBRL_Log::getInstance()->info( "Output instance document ({$this->label})" );
		}

		// Any additional namespaces
		if ( ! $this->factsContainer->namespaces )
		{
			$this->factsContainer->namespaces = $this->xbrlInstance->getInstanceNamespaces();
		}
		$namespaces =& $this->factsContainer->namespaces;

		$taxonomy = $this->xbrlTaxonomy;
		$primaryItems = $taxonomy->getDefinitionPrimaryItems( false );

		foreach ( $this->evaluationResults as $evaluationResultGUID => $evaluationResult )
		{
			// Only use results generated by this variable set.  Other results may exist added as a result of a scope variable arc.
			if ( isset( $evaluationResult['variableSet'] ) && $evaluationResult['variableSet'] != $this->label ) continue;

			// Clear any previous value
			$primaryItemRoles = null;

			if ( $evaluationResult['result'] instanceof XPath2NodeIterator )
			{
				$count = $evaluationResult['result']->getCount();
				if ( $count > 1 )
				{
					$log->formula_validation( "Formula", "The formula result is not a single value",
						array(
							'formula' => $this->label,
							'error' => 'xbrlfe:nonSingletonOutputValue'
						)
					);
				}

				if ( $count == 0 )
				{
					$evaluationResult['result'] = Undefined::getValue();
				}
				else
				{
					$evaluationResult['result']->rewind();
					$evaluationResult['result'] = $evaluationResult['result']->getCurrent()->getValue();
				}
			}

			// Source evaluation has to be done within the context of a
			// produced fact because the source may reference a variable

			// Use the concept aspect flag in case the formula source is formula:uncovered
			// If there is no valid source an exception will be thrown
			$sourceFact = $this->getSourceFact( $this->source, $evaluationResult, ASPECT_CONCEPT, \XBRL_Log::getInstance() );

			$contextRef = null;
			if ( $sourceFact )
			{
				// Get the context ref from the source
				$contextRef = FactValues::getContextRef( $sourceFact );
			}
			else
			{
				// Use the context ref of one of the formula variables
				$variableRefs = $this->getVariableRefs();
				foreach ( $variableRefs as $variableRef )
				{
					$contextFact = $this->getSourceFact( $variableRef, $evaluationResult, ASPECT_CONCEPT, \XBRL_Log::getInstance() );
					// As well as being null the returned context fact could be aN XPath2Item (fallback value)
					if ( ! $contextFact ) continue;
					if ( $contextFact instanceof XPath2NodeIterator )
					{
						$clone = $contextFact->CloneInstance();
						$clone->Reset();
						if ( $clone->MoveNext() )
						{
							$contextFact = $clone->getCurrent();
						}
					}
					if ( ! $contextFact instanceof DOMXPathNavigator ) continue;

					$contextRef = FactValues::getContextRef( $contextFact );
					break;
				}
			}

			// Get the unit ref from the source
			// $unitRef = FactValues::getUnitRef( $sourceFact );

			// Get the context of the formula source fact
			$orginalContext = $contextRef ? $this->xbrlInstance->getContext( $contextRef ) : array();

			// Get the concept RAV
			$conceptQName = $this->getConceptAspectQName( $sourceFact, $evaluationResult, $log );

			// Get the entity identifier RAV
			$entityIdentifier = $this->getEntityIdentifierAspectValue( $this->source, $evaluationResult, $log );

			// Get the location RAV
			$locationQName = $this->getLocationAspect( $this->source, $evaluationResult, $log );

			// Get the period RAV
			$period = $this->getPeriodAspectValue( $this->source, $evaluationResult, $log );

			// Get the scenario RAV
			$componentType = 'scenario';
			foreach ( Formula::$componentPaths as $componentPath )
			{
				if ( ! in_array( $componentType, $componentPath ) ) continue;
				$this->scenariosComponentPath = $componentPath;
				$scenarios = $this->getComponentAspectValue( $this->source, $this->aspectModel == 'dimensional' ? ASPECT_NON_XDT_SCENARIO : ASPECT_COMPLETE_SCENARIO, $componentType, $evaluationResult, $log );
				if ( $scenarios ) break;
			}

			// Get the segment RAV
			$componentType = 'segment';
			foreach ( Formula::$componentPaths as $componentPath )
			{
				if ( ! in_array( $componentType, $componentPath ) ) continue;
				$this->segmentsComponentPath = $componentPath;
				$segments = $this->getComponentAspectValue( $this->source, $this->aspectModel == 'dimensional' ? ASPECT_NON_XDT_SEGMENT : ASPECT_COMPLETE_SEGMENT, $componentType, $evaluationResult, $log );
				if ( $segments ) break;
			}

			$contextDimensions = array();
			$elementTaxonomy = $taxonomy->getTaxonomyForNamespace( $conceptQName->namespaceURI );
			$conceptElement = $elementTaxonomy->getElementByName( $conceptQName->localName );

			if ( $this->aspectModel == 'dimensional' )
			{
				// Remove any XDT components from the segments and scenarios list
				unset( $scenarios['explicitMember'] );
				unset( $scenarios['typedMember'] );
				unset( $segments['explicitMember'] );
				unset( $segments['typedMember'] );

				$conceptPrimaryItemId = "{$elementTaxonomy->getTaxonomyXSD()}#{$conceptElement['id']}";
				$contextDimensions = array();
				$typedDimensions = array();
				// Only need to process these if the target concept is a primary item
				if ( isset( $primaryItems[ $conceptPrimaryItemId ] ) )
				{
					$primaryItemRoles = $taxonomy->getPrimaryItemDRS( $primaryItems[ $conceptPrimaryItemId ]);

					// Record if ANY of the hyercubes linked to the primary item are not closed
					$isClosed = true;

					// Get a list of all the possoble explicit dimensions
					$explicitTaxonomyDimensions = array();
					$typedTaxonomyDimensions = array();

					foreach ( $primaryItemRoles as $HypercubeId => $roles )
					{
						foreach ( $roles as $roleUri => $details )
						{
							$contextElement = $details['parents'][ $conceptPrimaryItemId ]['contextElement'];

							if ( ! $details['parents'][ $conceptPrimaryItemId ]['closed'] )
							{
								$isClosed = false;
							}

							foreach ( $details['dimensions'] as $dimensionId => $dimension )
							{
								// Get the element
								$dimTaxonomy = $taxonomy->getTaxonomyForXSD( $dimensionId );
								$dimElement = $dimTaxonomy->getElementById( $dimensionId );
								$dimQName = new QName( null, $dimTaxonomy->getNamespace(), $dimElement['name'] );
								if ( ! isset( $dimension['explicit'] ) || $dimension['explicit'] )
								{
									$explicitTaxonomyDimensions[ $dimQName->clarkNotation() ] = $isClosed;
								}
								else
								{
									$typedTaxonomyDimensions[ $dimQName->clarkNotation() ] = $isClosed;
								}
							}
						}
					}

					// $explicitTaxonomyDimensions = array_unique( $explicitTaxonomyDimensions );
					// $typedTaxonomyDimensions = array_unique( $typedTaxonomyDimensions );

					$aspectsDefinedDimensions = array_reduce( $evaluationResult['defined'],
						function( $carry, $aspectsDefined ) {
							return array_unique( array_merge( $carry, array_filter( $aspectsDefined, function( $aspect ) { return $aspect[0] != '\\'; } ) ) );
						}, array() );

					foreach ( $aspectsDefinedDimensions as $aspectsDefinedDimension )
					{
						// Look to see if the aspect defined dimension is defined as a hypercube dimension
						if ( isset( $explicitTaxonomyDimensions[ $aspectsDefinedDimension ] ) ||
							 isset( $typedTaxonomyDimensions[ $aspectsDefinedDimension ] ) )
						{
							// It is so nothing to do
							continue;
						}

						if ( $isClosed )
						{
							// Can't warn here because a scenario is that there is a context dimension to be removed
						}

						// It's not so get the element find out if the dimension is typed or explicit
						$dimensionQName = qname( $aspectsDefinedDimension );
						$dimTaxonomy = $taxonomy->getTaxonomyForNamespace( $dimensionQName->namespaceURI );
						$dimElement = $dimTaxonomy->getElementByName( $dimensionQName->localName );
						if ( isset( $dimElement['typedDomainRef'] ) )
						{
							$typedTaxonomyDimensions[ $aspectsDefinedDimension ] = $isClosed;
						}
						else
						{
							$explicitTaxonomyDimensions[ $aspectsDefinedDimension ] = $isClosed;
						}
					}

					// This function has taken a lot of deliberation.  Here's a summary I'm writing in one of my less confused
					// moments. By this line $explicitTaxonomyDimensions will contain either a list of dimensions associated with
					// the hypercubes of the primary item and/or those which are uncovered dimensions.  A dimension is necessary
					// before calling getExplicitDimensionAspectValue() because this function and any rules is uses may need
					// to resolve the 'uncovered' QName if it is used as a rule source and this resolution will require the name
					// of an uncovered dimension.  As a result one of the following will be true.  If not, it means there will
					// be no OCC dimension values to worry about.
					//
					// 1) There are dimensions associated with the primary item hypercubes
					// 2) There are dimensions discovered and added to the 'aspectsDefined' list
					// 3) There are no dimensions but there is a rule that might add a dimension(*)
					//
					// These conditions are additive.  For example there may be hypercube dimensions and discovered dimensions
					// and one or more rules.
					// If there are no dimensions (hypercube or discovered) there may be one or more rules.  In this case
					// a dummy rule will be added to $explicitTaxonomyDimensions so the getExplicitDimensionAspectValue() will
					// be called.
					// Finally, there there is no information here about whether an exising uncovered dimension belongs to
					// a segment or scenario so definately not about whether the componet is a child of the entity node.
					// To handle this, the getExplicitDimensionAspectValue() may be called up to four times - once each for
					// the combinations of scenario/segment and entity/not entity child.
					//
					// These note apply equally to processing the $typedTaxonomyDimensions variable.

					if ( ! $explicitTaxonomyDimensions && $this->explicitDimensionRule )
					{
						// Add a dummy dimension so the rule(s) have chance to run
						$explicitTaxonomyDimensions[''] = $isClosed;
					}

					// BMS 2018-02-19 Updated to combine dimension results before validating them and their paths
					$dimensionsResult = array();
					// Get the explicit dimension RAV
					foreach ( $explicitTaxonomyDimensions as $dimension => $closed )
					foreach ( Formula::$componentPaths as $componentPath )
					{
						$componentType = in_array( "scenario", $componentPath ) ? 'scenario' : 'segment';

						// This class variable is used to pass component path information to the ExplicitDimension instance
						$this->explicitDimensionsComponentPath = $componentPath;
						$explicitDimensionsResult = $this->getExplicitDimensionAspectValue( $this->source, $componentPath, $evaluationResult, $dimension, $log );
						if ( $explicitDimensionsResult )
						{
							$dimensionsResult = array_merge( $dimensionsResult, $explicitDimensionsResult );
							// // Check the dimension(s) and primary item
							// // Chack is the segment/scenario path is consistent with the context element of the primary item
							// $componentPath = $this->validateContextDimensions( $taxonomy, $conceptPrimaryItemId, $explicitDimensionsResult, $primaryItemRoles, $componentPath );
							// $contextDimensions['explicitMember'][ $dimension ] = array(
							// 	'dimensions' => $explicitDimensionsResult,
							// 	'paths' => $componentPath
							// );
							break;
						}
					}

					if ( ! $typedTaxonomyDimensions && $this->typedDimensionRule )
					{
						// Add a dummy dimension so the rule(s) have chance to run
						$typedTaxonomyDimensions[''] = $isClosed;
					}

					// Get the typed dimension RAV
					foreach ( $typedTaxonomyDimensions as $dimension => $closed )
					foreach ( Formula::$componentPaths as $componentPath )
					{
						$componentType = in_array( "scenario", $componentPath ) ? 'scenario' : 'segment';

						// This class variable is used to pass component path information to the TypedDimension instance
						$this->typedDimensionsComponentPath = $componentPath;
						$typedDimensionsResult = $this->getTypedDimensionAspectValue( $this->source, $componentPath, $evaluationResult, $dimension, $log );
						if ( $typedDimensionsResult )
						{
							$dimensionsResult = array_merge( $dimensionsResult, $typedDimensionsResult );
							// // Check the dimension(s) and primary item
							// // Is the segment/scenario path is consistent with the context element of the primary item
							// $componentPath = $this->validateContextDimensions( $taxonomy, $conceptPrimaryItemId, $typedDimensionsResult, $primaryItemRoles, $componentPath );
							// $contextDimensions['typedMember'][ $dimension ] = array(
							// 	'dimensions' => $typedDimensionsResult,
							// 	'paths' => $componentPath
							// );
							break;
						}
					}

					// Check the dimension(s) and primary item
					$componentPath = $this->validateContextDimensionsAlt( $conceptPrimaryItemId, $dimensionsResult, $primaryItemRoles, $componentPath );
					$contextDimensions = array();
					foreach ( $dimensionsResult as $dimensionId => $members )
					{
						$qname = qname( $dimensionId, $this->nsMgr->getNamespaces() );
						$memberType = in_array( $qname->clarkNotation(), $this->typedDimensions ) ? 'typedMember' : 'explicitMember';
						if ( ! isset( $contextDimensions[ $memberType ][ $qname->clarkNotation() ] ) )
						{
							$contextDimensions[ $memberType ][ $qname->clarkNotation() ] = array(
								'dimensions' => array(),
								'paths' => $componentPath
							);
						}
						$contextDimensions[ $memberType ][ $qname->clarkNotation() ]['dimensions'] = array( $dimensionId => $members );
					}
				}
			}

			// Create a context
			$newContext = array();
			// Any additional namespaces
			// $namespaces = $this->xbrlInstance->getInstanceNamespaces();

			$addPath = function( $context, $path, $extra, $values )
			{
				$selected = &$context;
				foreach ( $path as $element )
				{
					if ( ! isset( $selected[ $element ] ) )
					{
						$selected[ $element ] = array();
					}

					$selected = &$selected[ $element ];
				}

				if ( $extra )
				{
					if ( ! isset( $selected[ $extra ] ) )
					{
						$selected[ $extra ] = array();
					}
					$selected = &$selected[ $extra ];
				}

				$selected = array_merge( $selected, $values );
				unset( $selected );

				return $context;
			};

			if ( $entityIdentifier )
			{
				$newContext['entity']['identifier'] = $entityIdentifier;
			}

			if ( $period )
			{
				$newContext['period'] = $period;
			}

			if ( $scenarios )
			{
				// Need to add the scenarios to the correct path
				$extra = $this->scenarioRule ? '' : '';
				$newContext = $addPath( $newContext, $this->scenariosComponentPath, $extra, $scenarios );
				// $newContext['scenario']['member'] = $scenarios;
			}

			if ( $segments )
			{
				// Need to add the segments to the correct path
				// BMS 2018-02-19 Conflict here between when an 'extra' value of member is needed and when not.
				// BMS 2018-03-22 I believe this issue is resolved.  An additional 'extra' value is not required.
				//				  See the note of the same date in getComponentAspectValue()
				//
				$extra = $this->segmentRule ? '' : '';
				$newContext = $addPath( $newContext, $this->segmentsComponentPath, $extra, $segments );
			}

			if ( $contextDimensions )
			{
				foreach ( $contextDimensions as $memberType => $dimensions )
				{
					foreach ( $dimensions as $aspectDimension => $details )
					{
						$paths = $details['paths'];
						$dimensions = Dimension::IndexToContext( $details['dimensions'] );
						$newContext = $addPath( $newContext, $paths, $memberType, $dimensions );
					}
				}
			}

			// $originalContextHash = $this->hashArray( $orginalContext );

			// A precautionary measure.  You know, just in case.
			if ( is_null( $this->factsContainer ) )
			{
				$this->factsContainer = new GeneratedFacts();
			}

			if ( ! $evaluationResult['isTuple'] )
			{
				$hash = $this->hashArray( $newContext );

				if ( isset( $this->factsContainer->contextHashes[ $hash['hash'] ] ) )
				{
					// Since it is equivalent to an existing context, use the existing context ref
					$contextRef = $this->factsContainer->contextHashes[ $hash['hash'] ];
				}
				else
				{
					if ( ! $contextRef )
					{
						$contextRef = "context";
					}

					if ( isset( $this->factsContainer->contexts[ $contextRef ] ) )
					{
						// The contextRef has been used but the hash is not the same
						// So generate a new context ref and carry on
						if ( isset( $this->factsContainer->contextRefIndexes[ $contextRef ] ) )
						{
							$index = $this->factsContainer->contextRefIndexes[ $contextRef ];
							$index++;
							$this->factsContainer->contextRefIndexes[ $contextRef ] = $index;
							$contextRef .= "-$index";
						}
						else
						{
							$index = 1;
							$this->factsContainer->contextRefIndexes[ $contextRef ] = $index;
							$contextRef .= "-$index";
						}
					}

					// // BMS 2018-04-04 Moved up
					// if ( ! $contextRef )
					// {
					// 	$contextRef = "context";
					// }

					$this->factsContainer->contextHashes[ $hash['hash'] ] = $contextRef;
					$this->factsContainer->contexts[ $contextRef ] = $newContext;
				}
			}

			// Create a fact
			$fact = array();

			// BMS 2018-04-01 Check to see if the qname namespace is a taxonomy
			$tax = $this->xbrlTaxonomy->getTaxonomyForNamespace( $conceptQName->namespaceURI );
			if ( $tax )
			{
				// Set the qname prefix
				$conceptQName->prefix = $tax->getPrefix();
			}

			// If this prefix does not exist in the namespace list add it.
			if ( ! isset( $namespaces[ $conceptQName->prefix ] ) )
			{
				$namespaces[ $conceptQName->prefix ] = $conceptQName->namespaceURI;
			}

			$fact['concept'] = $conceptQName;
			$fact['contextRef'] = $evaluationResult['isTuple'] ? null : $contextRef;

			if ( $evaluationResult['result'] instanceof Undefined )
			{
				$fact['value'] = null;
			}
			else if ( $evaluationResult['result'] instanceof DOMXPathNavigator )
			{
				$value = $evaluationResult['result']->getValue();
				$fact['value'] = ! $value && FactValues::isNull( $evaluationResult['result'] )
					? null
					: $value;
			}
			else
			{
				$fact['value'] = $evaluationResult['result'] instanceof XPath2Item || $evaluationResult['result'] instanceof DecimalValue
					  ? $evaluationResult['result']->getValue()
					  : ( $evaluationResult['result'] instanceof CoreFuncs::$False
					  		? "false"
					  		: ( $evaluationResult['result'] instanceof CoreFuncs::$True
					  				? 'true'
					  				: $evaluationResult['result']
					  		  )
						);
			}

			$unit = null;
			$typeIsNumeric = false;
			// BMS 2018-04-09 Extra test candidate not required any more but it doesn't hurt.
			if ( \XBRL_Types::getInstance()->resolvesToBaseType( $conceptElement['type'], array( 'xs:decimal', 'xsd:decimal' ) ) )
			{
				$typeIsNumeric = true;
				// Create a unit
				$unit = $this->getUnitAspectValue( $this->source, $evaluationResult, $log );
				$unitRule = Unit::fromArray( $this->unitRule );
				$namespaces = array_merge( $namespaces, $unitRule->getAdditionalNamespaces( $this, $evaluationResult ) );
			}

			if ( $typeIsNumeric && is_numeric( $fact['value'] ) )
			{
				if ( ! is_null( $this->precisionRule ) )
				{
					if ( is_numeric( $this->precisionRule ) )
					{
						$fact['precision'] = $this->precisionRule;
					}
					else
					{
						if ( ! $this->precisionRuleXPath )
						{
							$this->precisionRuleXPath = XPath2Expression::Compile( $this->precisionRule, $this->nsMgr );
						}

						$result = CoreFuncs::Atomize( $this->evaluateXPathExpression( $this, $this->precisionRuleXPath, $this->getParametersAsVars( $evaluationResult['vars'] ) ) );
						$fact['precision'] = $result instanceof XPath2Item
							? $result->getValue()
							: $result;
					}
				}
				else if ( ! is_null( $this->decimalsRule ) )
				{
					if ( is_numeric( $this->decimalsRule ) )
					{
						$fact['decimals'] = $this->decimalsRule;
					}
					else
					{
						if ( ! $this->decimalsRuleXPath )
						{
							$this->decimalsRuleXPath = XPath2Expression::Compile( $this->decimalsRule, $this->nsMgr );
						}

						$result = CoreFuncs::Atomize( $this->evaluateXPathExpression( $this, $this->decimalsRuleXPath, $this->getParametersAsVars( $evaluationResult['vars'] ) ) );
						$fact['decimals'] = $result instanceof XPath2Item
							? $result->getValue()
							: $result;
					}
				}
				else
				{
					// This is the default rule specified in the formula specification section 2.1.1.1 (last sentence).
					$fact['precision'] = "0";
				}

				if ( isset( $fact['decimals'] ) )
				{
					$fact['value'] = number_format( $fact['value'], $fact['decimals'] == INF || $fact['decimals'] == 'INF' ? null : $fact['decimals'], ".", "" );
				}
			}

			if ( $unit )
			{
				$hash = $this->hashArray( reset( $unit ) );
				if ( isset( $this->factsContainer->unitHashes[ $hash['hash'] ] ) )
				{
					// Since it is equivalent to an existing unit, use the existing unit ref
					$unitRef = $this->factsContainer->unitHashes[ $hash['hash'] ];
				}
				else
				{
					$unitRef = key( $unit );
					if ( isset( $this->factsContainer->units[ $unitRef ] ) )
					{
						// The unitRef has been used but the hash is not the same
						// So generate a new context ref and carry on
						if ( isset( $this->factsContainer->unitRefIndexes[ $unitRef ] ) )
						{
							$index = $this->factsContainer->unitRefIndexes[ $unitRef ];
							$index++;
							$this->factsContainer->unitRefIndexes[ $unitRef ] = $index;
							$unitRef .= "-$index";
						}
						else
						{
							$index = 1;
							$this->factsContainer->unitRefIndexes[ $unitRef ] = $index;
							$unitRef .= "-$index";
						}
					}

					$this->factsContainer->unitHashes[ $hash['hash'] ] = $unitRef;
					$this->factsContainer->units[ $unitRef ] = reset( $unit );
				}

				$fact['unitRef'] = $unitRef;
			}
			else
			{
				// If the fact is numeric then there MUST be a unit RAV
				if ( $typeIsNumeric && is_numeric( $fact['value'] ) )
				{
					$log->formula_validation( "Unit aspect", "No aspect for numeric fact",
						array(
							'formula' => $this->label,
							'error' => 'xbrlfe:missingUnitRule'
						)
					);
				}
			}

			// Copy over any tuple information
			if ( isset( $evaluationResult['tuple'] ) )
			{
				$fact['tuple'] = $evaluationResult['tuple'];
				$fact['parentTupleGUID'] = $evaluationResult['parentTupleGUID'];
			}

			$fact['isTuple'] = $evaluationResult['isTuple'];

			$this->factsContainer->facts[ $this->label ][ $evaluationResultGUID ] = $fact;
			$this->factsContainer->vars[ $this->label ][ $evaluationResultGUID ] = $evaluationResult['vars'];
			$this->factsContainer->sources[ $this->label ] = $this->conceptRule ? null : $sourceFact;
			// $this->factsContainer->namespaces = $namespaces;
		}
	}
1313353
public function addLog(Log $log)
    {
        $log->setInstance($this);
        $this->getLogs()->add($log);
    }
603104
public function makeLog()
    {
        $log = new UserProgressLog();
        $log->setUser($this->user);
        $log->setPercentage($this->percentage);
        $log->setDate($this->date);

        return $log;
    }
1031012
public function makeLog()
    {
        $log = new CompetencyProgressLog();
        $log->setCompetency($this->competency);
        $log->setUser($this->user);
        $log->setPercentage($this->percentage);
        $log->setDate($this->date);

        if ($this->level) {
            $log->setLevel($this->level);
        }

        return $log;
    }
1116846
public function generateResults()
    {
        if (!$this->isEnabled) {
            return '';
        }

        // Calculate times and keys for the tsStackLog
        foreach ($this->tsStackLog as $uniqueId => &$data) {
            $data['endtime'] = $this->getDifferenceToStarttime($data['endtime']);
            $data['starttime'] = $this->getDifferenceToStarttime($data['starttime']);
            $data['deltatime'] = $data['endtime'] - $data['starttime'];
            if (is_array($data['tsStack'])) {
                $data['key'] = implode($data['stackPointer'] ? '.' : '/', end($data['tsStack']));
            }
        }

        unset($data);

        // Create hierarchical array of keys pointing to the stack
        $arr = [];
        foreach ($this->tsStackLog as $uniqueId => $data) {
            $this->createHierarchyArray($arr, $data['level'], $uniqueId);
        }

        // Parsing the registered content and create icon-html for the tree
        $this->tsStackLog[$arr['0.'][0]]['content'] = $this->fixContent($arr['0.'], $this->tsStackLog[$arr['0.'][0]]['content'], '', 0, $arr['0.'][0]);

        // Displaying the tree:
        $outputArr = [];
        $outputArr[] = $this->fw('TypoScript Key');
        $outputArr[] = $this->fw('Value');
        if ($this->printConf['allTime']) {
            $outputArr[] = $this->fw('Time');
            $outputArr[] = $this->fw('Own');
            $outputArr[] = $this->fw('Sub');
            $outputArr[] = $this->fw('Total');
        } else {
            $outputArr[] = $this->fw('Own');
        }
        $outputArr[] = $this->fw('Details');

        $out = '';
        $foo = ['headers'];
        foreach ($outputArr as $row) {
            $out .= '<th>' . $row . '</th>';
            $foo['headers'][] .= $row;
        }
        $out = '<thead><tr>' . $out . '</tr></thead>';
        $flag_tree = $this->printConf['flag_tree'];
        $flag_messages = $this->printConf['flag_messages'];
        $flag_content = $this->printConf['flag_content'];
        $keyLgd = $this->printConf['keyLgd'];
        $c = 0;
        foreach ($this->tsStackLog as $uniqueId => $data) {
            if ($this->highlightLongerThan && (int)$data['owntime'] > (int)$this->highlightLongerThan) {
                $logRowClass = 'typo3-debugbar-logRow-highlight';
            } else {
                $logRowClass = $c % 2 ? 'line-odd' : 'line-even';
            }
            $item = '';
            // If first...
            if (!$c) {
                $data['icons'] = '';
                $data['key'] = 'Script Start';
                $data['value'] = '';
            }
            // Key label:
            $keyLabel = '';
            if (!$flag_tree && $data['stackPointer']) {
                $temp = [];
                foreach ($data['tsStack'] as $k => $v) {
                    $temp[] = GeneralUtility::fixed_lgd_cs(implode($v, $k ? '.' : '/'), -$keyLgd);
                }
                array_pop($temp);
                $temp = array_reverse($temp);
                array_pop($temp);
                if (!empty($temp)) {
                    $keyLabel = '<br /><span style="color:#999999;">' . implode($temp, '<br />') . '</span>';
                }
            }
            if ($flag_tree) {
                $tmp = GeneralUtility::trimExplode('.', $data['key'], true);
                $theLabel = end($tmp);
            } else {
                $theLabel = $data['key'];
            }
            $theLabel = GeneralUtility::fixed_lgd_cs($theLabel, -$keyLgd);
            $theLabel = $data['stackPointer'] ? '<span class="stackPointer">' . $theLabel . '</span>' : $theLabel;
            $keyLabel = $theLabel . $keyLabel;
            $item .= '<td class="typo3-debugbar-table-cell-nowrap ' . $logRowClass . '">' . ($flag_tree ? $data['icons'] : '') . $this->fw($keyLabel) . '</td>';
            // Key value:
            $keyValue = $data['value'];
            $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime">' . $this->fw(htmlspecialchars($keyValue)) . '</td>';
            if ($this->printConf['allTime']) {
                $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime"> ' . $this->fw($data['starttime']) . '</td>';
                $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>';
                $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime"> ' . $this->fw(($data['subtime'] ? '+' . $data['subtime'] : '')) . '</td>';
                $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime"> ' . $this->fw(($data['subtime'] ? '=' . $data['deltatime'] : '')) . '</td>';
            } else {
                $item .= '<td class="' . $logRowClass . ' typo3-debugbar-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>';
            }
            // Messages:
            $msgArr = [];
            $msg = '';
            if ($flag_messages && is_array($data['message'])) {
                foreach ($data['message'] as $v) {
                    $msgArr[] = nl2br($v);
                }
            }
            if ($flag_content && (string)$data['content'] !== '') {
                $maxlen = 120;
                // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...)
                if (preg_match_all('/(\\S{' . $maxlen . ',})/', $data['content'], $reg)) {
                    foreach ($reg[1] as $key => $match) {
                        $match = preg_replace('/(.{' . $maxlen . '})/', '$1 ', $match);
                        $data['content'] = str_replace($reg[0][$key], $match, $data['content']);
                    }
                }
                $msgArr[] = nl2br($data['content']);
            }
            if (!empty($msgArr)) {
                $msg = implode($msgArr, '<hr />');
            }
            $item .= '<td class="typo3-debugbar-table-cell-content">' . $this->fw($msg) . '</td>';
            $out .= '<tr>' . $item . '</tr>';
            $c++;
        }
        $output = '<table class="typo3-debugbar-table">' . $out . '</table>';

        return $output;
    }
1134644
public function col_outcomes(stdClass $row) {
        $outcomes = '';
        foreach ($this->gradinginfo->outcomes as $index => $outcome) {
            $options = make_grades_menu(-$outcome->scaleid);

            $options[0] = get_string('nooutcome', 'grades');
            if ($this->quickgrading && !($outcome->grades[$row->userid]->locked)) {
                $select = '<select name="outcome_' . $index . '_' . $row->userid . '" class="quickgrade">';
                foreach ($options as $optionindex => $optionvalue) {
                    $selected = '';
                    if ($outcome->grades[$row->userid]->grade == $optionindex) {
                        $selected = 'selected="selected"';
                    }
                    $select .= '<option value="' . $optionindex . '"' . $selected . '>' . $optionvalue . '</option>';
                }
                $select .= '</select>';
                $outcomes .= $this->output->container($outcome->name . ': ' . $select, 'outcome');
            } else {
                $name = $outcome->name . ': ' . $options[$outcome->grades[$row->userid]->grade];
                if ($this->is_downloading()) {
                    $outcomes .= $name;
                } else {
                    $outcomes .= $this->output->container($name, 'outcome');
                }
            }
        }

        return $outcomes;
    }
1143124
public function parseLog($log)
    {
        $commits = $tags = [];

        for ($i = 0, $lines = count($log); $i < $lines; $i++) {
            $tmp = explode(': ', $log[$i]);
            $tmp = array_map('trim', $tmp);

            if ($tmp[0] == 'changeset') {
                $commit = $tmp[1];
            }

            if ($tmp[0] == 'user') {
                $email  = $this->extractEmail($tmp[1]);
                $author = $this->extractAuthor($tmp[1]);
            }

            if ($tmp[0] == 'date') {
                $date = trim($tmp[1]);
            }

            if ($tmp[0] == 'tag') {
                $tags[] = trim($tmp[1]);
            }

            if ($tmp[0] == 'summary') {
                $commits[] = [
                    'commit'  => trim($commit),
                    'author'  => trim($author),
                    'email'   => trim($email),
                    'date'    => DateTime::createFromFormat('D M j H:i:s Y O', $date),
                    'summary' => trim($tmp[1]),
                    'tags'    => $tags,
                    'vcs'     => trim($this->repository_type),
                ];
                $tags = [];
            }
        }

        return $commits;
    }
1310963
protected function ansi2Html($log)
    {
        $string = html_entity_decode(
            $this->ansiConverter->convert($log)
        );

        $string = str_replace("\r\n", '<br>', $string);

        $string = str_replace("\n", '<br>', $string);

        return $string;
    }
478771
protected function renderTableRow($log)
    {
        $color = LogViewer::$levelColors[$log['level']] ?? 'black';

        $index = uniqid();

        $button = '';

        if (!empty($log['trace'])) {
            $button = "<a class=\"btn btn-primary btn-xs\" data-toggle=\"collapse\" data-target=\".trace-{$index}\"><i class=\"fa fa-info\"></i>&nbsp;&nbsp;Exception</a>";
        }

        $trace = '';

        if (!empty($log['trace'])) {
            $trace = "<tr class=\"collapse trace-{$index}\">
    <td colspan=\"5\"><div style=\"white-space: pre-wrap;background: #333;color: #fff; padding: 10px;\">{$log['trace']}</div></td>
</tr>";
        }

        return <<<TPL
<tr style="background-color: rgb(255, 255, 213);">
    <td><span class="label bg-{$color}">{$log['level']}</span></td>
    <td><strong>{$log['env']}</strong></td>
    <td  style="width:150px;">{$log['time']}</td>
    <td><code>{$log['info']}</code></td>
    <td>$button</td>
</tr>
$trace
TPL;

    }
843564
protected function logQuery()
    {
        $info = $this->info();

        if (!$info['started_iterating']) {
            if (!is_array($info['query'])) {
                $info['query'] = array();
            } else if (!isset($info['query']['$query'])) {
                $info['query'] = array('$query' => $info['query']);
            }

            // explain cursor
            $this->explainCursor->fields($info['fields']);
            $this->explainCursor->limit($info['limit']);
            $this->explainCursor->skip($info['skip']);
            if (isset($info['batchSize'])) {
                $this->explainCursor->batchSize($info['batchSize']);
            }
            if (isset($info['query']['$orderby'])) {
                $this->explainCursor->sort($info['query']['$orderby']);
            }
            if (isset($info['query']['$hint'])) {
                $this->explainCursor->hint($info['query']['$hint']);
            }
            if (isset($info['query']['$snapshot'])) {
                $this->explainCursor->snapshot();
            }
            $explain = $this->explainCursor->explain();

            // log
            $log = array(
                'type'   => $this->type,
                'query'  => isset($info['query']['$query']) && is_array($info['query']['$query']) ? $info['query']['$query'] : array(),
                'fields' => $info['fields'],
            );
            if (isset($info['query']['$orderby'])) {
                $log['sort'] = $info['query']['$orderby'];
            }
            if ($info['limit']) {
                $log['limit'] = $info['limit'];
            }
            if ($info['skip']) {
                $log['skip'] = $info['skip'];
            }
            if ($info['batchSize']) {
                $log['batchSize'] = $info['batchSize'];
            }
            if (isset($info['query']['$hint'])) {
                $log['hint'] = $info['query']['$hint'];
            }
            if (isset($info['query']['$snapshot'])) {
                $log['snapshot'] = 1;
            }
            $log['explain'] = array(
                'nscanned'        => $explain['nscanned'],
                'nscannedObjects' => $explain['nscannedObjects'],
                'n'               => $explain['n'],
                'indexBounds'     => $explain['indexBounds'],
            );
            $log['time'] = $explain['millis'];

            $this->log($log);
        }
    }
1351650
public function details($log, array $levels, $entries, $level = null)
    {
        $this->breadcrumb->onSystem();
        $dataTable = $this->errorLogDetailsTable->html();
        return $this->view('details', compact('dataTable', 'log', 'levels', 'entries', 'level'));
    }
672366
protected function getLog()
    {
        if ($this->log == null) {
            $this->log = Tlog::getNewInstance();

            $logFilePath = $this->getLogFilePath();

            $this->log->setPrefix("#LEVEL: #DATE #HOUR: ");
            $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile");
            $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath);
            $this->log->setLevel(Tlog::INFO);
        }

        return $this->log;
    }
933399
public function formatGeneralInfo()
    {
        $log = "cl=" . \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView()->getClassName();
        if (($fnc = \OxidEsales\Eshop\Core\Registry::getConfig()->getActiveView()->getFncName())) {
            $log .= " fnc=$fnc";
        }

        return $log;
    }
1296892
protected function _report($log)
    {
        $type = $log->type();
        $this->_reportSuiteMessages($log);
        $this->_reportSpecMessage($log);
        $this->_reportFailure($log);
        $this->_indent = 0;
    }
13787
public function col_select(stdClass $row) {
        $selectcol = '<label class="accesshide" for="selectuser_' . $row->userid . '">';
        $selectcol .= get_string('selectuser', 'assign', $this->assignment->fullname($row));
        $selectcol .= '</label>';
        $selectcol .= '<input type="checkbox"
                              id="selectuser_' . $row->userid . '"
                              name="selectedusers"
                              value="' . $row->userid . '"/>';
        $selectcol .= '<input type="hidden"
                              name="grademodified_' . $row->userid . '"
                              value="' . $row->timemarked . '"/>';
        $selectcol .= '<input type="hidden"
                              name="gradeattempt_' . $row->userid . '"
                              value="' . $row->attemptnumber . '"/>';
        return $selectcol;
    }
805281
public function log(array $log)
    {
        $log['db'] = $this->database->getName();
        $log['collection'] = $this->getName();
        call_user_func($this->loggerCallable, $log);
    }