@param string $uri
@param string $selector
@param bool $debug
@param int $lifetime

@return string
@throws \Neos\Cache\Exception\InvalidDataException
337859
public function getContent($uri, $selector, $debug = FALSE, $lifetime = 3600) {
		$cacheIdentifier = sha1($uri . $selector);
		$buffer = $this->cache->get($cacheIdentifier);

		if($buffer === FALSE) {
			libxml_use_internal_errors(TRUE);
			$domDocument = new \DOMDocument();
			$domDocument->loadHTMLFile($uri, LIBXML_NOERROR|LIBXML_NOWARNING);
			$this->detectBaseUri($domDocument, $uri);
			$this->fixRelativeUris($domDocument, 'a', 'href');
			$this->fixRelativeUris($domDocument, 'img', 'src');
			$node = $domDocument->getElementById($selector);
			$buffer = $domDocument->saveHTML($node);
			libxml_clear_errors();
			libxml_use_internal_errors(FALSE);
			$this->cache->set($cacheIdentifier, $buffer, array(sha1($uri)), $lifetime);
		}

		return $buffer;
	}
296336
public function setCache($key, $data, $lifetimeInSeconds = false)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                /* escape query data */
                $_key = $this->sql->real_escape_string($key);
                $_data = $this->sql->real_escape_string(serialize($data));
                $_expire = $this->getExpirationTimestamp($lifetimeInSeconds);

                $response = $this->sql->query("
                    SELECT *
                        FROM `{$this->table}`
                        WHERE
                            `{$this->key}` = '$_key'
                ");
                if ($response->fetch_assoc()) {
                    if ($this->sql->query("
                        UPDATE
                            `{$this->table}`
                            SET
                                `{$this->cache}` = '$_data',
                                `expire` = " . ($_expire === false ? 'NULL' : "'$_expire'") . "
                            WHERE
                                `{$this->key}` = '$_key'
                    ")) {
                        return true;
                    } else {
                        throw new SimpleCache_Exception(
                            'Could not update existing cache data. ' . $this->sql->error,
                            SimpleCache_Exception::CACHE_WRITE
                        );
                    }
                } elseif ($this->sql->query("
                    INSERT
                        INTO `{$this->table}`
                        (
                            `{$this->key}`,
                            `{$this->cache}`
                            " . ($_expire === false ? '' : ", `expire`") . "
                        ) VALUES (
                            '$_key',
                            '$_data'
                            " . ($_expire === false ? '' : ", '$_expire'") . "
                        )
                ")) {
                    return true;
                } else {
                    throw new SimpleCache_Exception(
                        'Could not insert new cache data. ' . $this->sql->error,
                        SimpleCache_Exception::CACHE_WRITE
                    );
                }
            }
            return false;
        }
    }
25786
public function getExif($debug = false)
		# Author:     Jarrod Oberto
		# Date:       07-05-2011
		# Purpose:    Get image EXIF data
		# Param in:   n/a
		# Param out:  An associate array of EXIF data
		# Reference:
		# Notes:
		# 23 May 13 : added orientation flag -jco
		#
	{

		if ( ! $this->debug || ! $debug)
		{
			$debug = false;
		}

		// *** Check all is good - check the EXIF library exists and the file exists, too.
		if ( ! $this->testEXIFInstalled())
		{
			if ($debug)
			{
				throw new Exception('The EXIF Library is not installed.');
			}
			else
			{
				return array();
			}
		};
		if ( ! file_exists($this->fileName))
		{
			if ($debug)
			{
				throw new Exception('Image not found.');
			}
			else
			{
				return array();
			}
		};
		if ($this->fileExtension != '.jpg')
		{
			if ($debug)
			{
				throw new Exception('Metadata not supported for this image type.');
			}
			else
			{
				return array();
			}
		};
		$exifData = exif_read_data($this->fileName, 'IFD0');

		// *** Format the apperture value
		$ev = $exifData['ApertureValue'];
		$apPeicesArray = explode('/', $ev);
		if (count($apPeicesArray) == 2)
		{
			$apertureValue = round($apPeicesArray[0] / $apPeicesArray[1], 2, PHP_ROUND_HALF_DOWN) . ' EV';
		}
		else
		{
			$apertureValue = '';
		}

		// *** Format the focal length
		$focalLength = $exifData['FocalLength'];
		$flPeicesArray = explode('/', $focalLength);
		if (count($flPeicesArray) == 2)
		{
			$focalLength = $flPeicesArray[0] / $flPeicesArray[1] . '.0 mm';
		}
		else
		{
			$focalLength = '';
		}

		// *** Format fNumber
		$fNumber = $exifData['FNumber'];
		$fnPeicesArray = explode('/', $fNumber);
		if (count($fnPeicesArray) == 2)
		{
			$fNumber = $fnPeicesArray[0] / $fnPeicesArray[1];
		}
		else
		{
			$fNumber = '';
		}

		// *** Resolve ExposureProgram
		if (isset($exifData['ExposureProgram']))
		{
			$ep = $exifData['ExposureProgram'];
		}
		if (isset($ep))
		{
			$ep = $this->resolveExposureProgram($ep);
		}


		// *** Resolve MeteringMode
		$mm = $exifData['MeteringMode'];
		$mm = $this->resolveMeteringMode($mm);

		// *** Resolve Flash
		$flash = $exifData['Flash'];
		$flash = $this->resolveFlash($flash);


		if (isset($exifData['Make']))
		{
			$exifDataArray['make'] = $exifData['Make'];
		}
		else
		{
			$exifDataArray['make'] = '';
		}

		if (isset($exifData['Model']))
		{
			$exifDataArray['model'] = $exifData['Model'];
		}
		else
		{
			$exifDataArray['model'] = '';
		}

		if (isset($exifData['DateTime']))
		{
			$exifDataArray['date'] = $exifData['DateTime'];
		}
		else
		{
			$exifDataArray['date'] = '';
		}

		if (isset($exifData['ExposureTime']))
		{
			$exifDataArray['exposure time'] = $exifData['ExposureTime'] . ' sec.';
		}
		else
		{
			$exifDataArray['exposure time'] = '';
		}

		if ($apertureValue != '')
		{
			$exifDataArray['aperture value'] = $apertureValue;
		}
		else
		{
			$exifDataArray['aperture value'] = '';
		}

		if (isset($exifData['COMPUTED']['ApertureFNumber']))
		{
			$exifDataArray['f-stop'] = $exifData['COMPUTED']['ApertureFNumber'];
		}
		else
		{
			$exifDataArray['f-stop'] = '';
		}

		if (isset($exifData['FNumber']))
		{
			$exifDataArray['fnumber'] = $exifData['FNumber'];
		}
		else
		{
			$exifDataArray['fnumber'] = '';
		}

		if ($fNumber != '')
		{
			$exifDataArray['fnumber value'] = $fNumber;
		}
		else
		{
			$exifDataArray['fnumber value'] = '';
		}

		if (isset($exifData['ISOSpeedRatings']))
		{
			$exifDataArray['iso'] = $exifData['ISOSpeedRatings'];
		}
		else
		{
			$exifDataArray['iso'] = '';
		}

		if ($focalLength != '')
		{
			$exifDataArray['focal length'] = $focalLength;
		}
		else
		{
			$exifDataArray['focal length'] = '';
		}

		if (isset($ep))
		{
			$exifDataArray['exposure program'] = $ep;
		}
		else
		{
			$exifDataArray['exposure program'] = '';
		}

		if ($mm != '')
		{
			$exifDataArray['metering mode'] = $mm;
		}
		else
		{
			$exifDataArray['metering mode'] = '';
		}

		if ($flash != '')
		{
			$exifDataArray['flash status'] = $flash;
		}
		else
		{
			$exifDataArray['flash status'] = '';
		}

		if (isset($exifData['Artist']))
		{
			$exifDataArray['creator'] = $exifData['Artist'];
		}
		else
		{
			$exifDataArray['creator'] = '';
		}

		if (isset($exifData['Copyright']))
		{
			$exifDataArray['copyright'] = $exifData['Copyright'];
		}
		else
		{
			$exifDataArray['copyright'] = '';
		}

		// *** Orientation
		if (isset($exifData['Orientation']))
		{
			$exifDataArray['orientation'] = $exifData['Orientation'];
		}
		else
		{
			$exifDataArray['orientation'] = '';
		}

		return $exifDataArray;
	}
1077202
protected function getPathUrl($repositoryId, $path, $selector = null)
    {
        $result = $this->getRepositoryUrlCache()->getPathUrl($repositoryId, $path, $selector);

        if ($result === null) {
            $this->getRepositoriesInternal($repositoryId);
            $result = $this->getRepositoryUrlCache()->getPathUrl($repositoryId, $path, $selector);
        }

        if ($result === null) {
            throw new CmisObjectNotFoundException(
                sprintf(
                    'Unknown path! Repository: "%s" | Path: "%s" | Selector: "%s"',
                    $repositoryId,
                    $path,
                    $selector
                )
            );
        }

        return $result;
    }
10718
protected function getViewsState($url = '', $force = false, $selector = '__VIEWSTATE')
    {
        $url = $url ?: Config::get('url.main_page');
        $cacheKey = 'view_state-' . $this->getUserName() . '-' . md5($url);
        if ($force || !$viewState = $this->getCache()->fetch($cacheKey)) {
            $response = $this->request('get', [$url]);

            if (!$response) {
                throw new HttpException('get the param v failed', 10001);
            }

            if (!$viewState = Parser::fieldName($response->getBody(), $selector)) {
                throw new HttpException('get the param v failed', 10001);
            }

            $this->getCache()->save($cacheKey, $viewState, Config::get('cache.expire', 100));
        }

        return $viewState;
    }
1276701
public function handleException(\Throwable $throwable, bool $debug = false): ResponseInterface
    {
        $apiError = Error::createFrom($throwable, $debug);

        $document = $this->singleResourceDocument();
        $document->errors()->add($apiError);


        return new DocumentResponse($document, null, $apiError->status());
    }
1233962
public function save($id, $data, $lifeTime = 0)
    {
        return $this->cacheProvider->save($id, $data, $lifeTime);
    }
100834
public static function create(array $containerConfig, bool $debug){
        $startedAt  = microtime(true);
        $timeline   = [];

        // Container initialize
        $start              = microtime(true);
        $containerConfig    = static::createContainerConfigList($containerConfig, $debug, $startedAt);
        $containerFactory   = new ContainerFactory();
        $end                = microtime(true);

        $timeline["container.initialize"]   = [$start, $end];

        // Create container
        $start      = microtime(true);
        $container  = $containerFactory->createWithConfig($containerConfig, true);
        $end        = microtime(true);

        $timeline["container.create"]  = [$start, $end];

        // Create Application
        // コンテナのmodifyでappを触っているとすごく速くなる
        $start  = microtime(true);
        $app    = $container->get("app");
        $end    = microtime(true);

        $timeline["app.create"]  = [$start, $end];

        if(!($app instanceof static)){
            throw new \LogicException;
        }

        if($debug){
            foreach($timeline as $name => $time){
                $container->get("core.debugbar.performance")->addLine($name, $time[0], $time[1]);
            }
        }

        return $app;
    }
443765
protected final String prepareUri(final URI uri) {
        if (compareRelative) {
            final String path = uri.getRawPath();
            final String query = uri.getRawQuery();
            final String fragment = uri.getRawFragment();
            if (query != null && fragment != null) {
                return path + "?" + query + "#" + fragment;
            } else if (query != null) {
                return path + "?" + query;
            } else if (fragment != null) {
                return path + "#" + fragment;
            } else {
                return path;
            }
        } else {
            return uri.toString();
        }
    }
578550
protected function finalRender( $debug_data )
	{
		parent::finalRender( $debug_data );

		$url = \Sifo\Urls::getInstance()->getUrlConfig();
		echo '[INFO] Script debug properly saved. You can check it out at: ' . $url['sifo_debug_analyzer'] . '?execution_key=' . \Sifo\Debug::getExecutionKey() . PHP_EOL;
	}
1032505
public static function resolve(Uri $baseUri, Uri $targetUri)
    {
        if (!$baseUri->isAbsolute()) {
            throw new InvalidArgumentException('Base uri must be absolute');
        }

        // if the target uri is absolute
        if ($targetUri->isAbsolute()) {
            $path = $targetUri->getPath();

            if (!empty($path)) {
                return $targetUri->withPath($path);
            } else {
                return $targetUri;
            }
        } else {
            $authority = $targetUri->getAuthority();
            $path      = $targetUri->getPath();
            $query     = $targetUri->getQuery();

            if (!empty($authority)) {
                if (!empty($path)) {
                    $path = self::removeDotSegments($path);
                }
            } else {
                if (empty($path)) {
                    if (empty($query)) {
                        $path  = $baseUri->getPath();
                        $query = $baseUri->getQuery();
                    } else {
                        $path = self::merge($baseUri->getPath(), '');
                    }
                } else {
                    if (substr($path, 0, 1) == '/') {
                        $path = self::removeDotSegments($path);
                    } else {
                        $path = self::merge($baseUri->getPath(), $path);
                        $path = self::removeDotSegments($path);
                    }
                }

                $authority = $baseUri->getAuthority();
            }

            return new Uri(
                $baseUri->getScheme(),
                $authority,
                $path,
                $query,
                $targetUri->getFragment()
            );
        }
    }
1352624
public void endElement(String uri, String name, String qName)
    {
        boolean isDebug = logger.isDebugEnabled();
        try
        {
            switch (getLiteralId(qName))
            {
                case MAPPING_REPOSITORY:
                    {
                        currentAttributeContainer = null;
                        break;
                    }
                case CLASS_DESCRIPTOR:
                    {
                        currentAttributeContainer = null;
                        break;
                    }
                case JDBC_CONNECTION_DESCRIPTOR:
                    {
                        logger.debug("   < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
                        m_CurrentJCD = null;
                        currentAttributeContainer = null;
                        break;
                    }
                case CONNECTION_POOL:
                    {
                        logger.debug("   < " + tags.getTagById(CONNECTION_POOL));
                        currentAttributeContainer = m_CurrentJCD;
                        break;
                    }
                case SEQUENCE_MANAGER:
                    {
                        if (isDebug) logger.debug("    < " + tags.getTagById(SEQUENCE_MANAGER));
                        // set to null at the end of the tag!!
                        this.currentSequenceDescriptor = null;
                        currentAttributeContainer = m_CurrentJCD;
                        break;
                    }
                case OBJECT_CACHE:
                    {
                        if(currentAttributeContainer != null)
                        {
                            if (isDebug) logger.debug("    < " + tags.getTagById(OBJECT_CACHE));
                            // set to null or previous element level at the end of the tag!!
                            currentAttributeContainer = m_CurrentJCD;
                        }
                        break;
                    }
                case ATTRIBUTE:
                    {
                        if(currentAttributeContainer != null)
                        {
                            if (isDebug) logger.debug("      < " + tags.getTagById(ATTRIBUTE));
                        }
                        break;
                    }
                default :
                    {
                        // noop
                    }
            }
        }
        catch (Exception ex)
        {
            logger.error(ex);
            throw new PersistenceBrokerException(ex);
        }
    }
295852
protected function _parseUri($uri)
    {
        $parts = parse_url($uri);

        if (false === $parts) {
            throw new \InvalidArgumentException(
                'The source URI string appears to be malformed'
            );
        }

        $this->_scheme    = isset($parts['scheme'])   ? $this->_filterScheme($parts['scheme']) : '';
        $this->_userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->_host      = isset($parts['host'])     ? $parts['host']     : '';
        $this->_port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->_path      = isset($parts['path'])     ? $this->_filterPath($parts['path']) : '';
        $this->_query     = isset($parts['query'])    ? $this->_filterQuery($parts['query']) : '';
        $this->_fragment  = isset($parts['fragment']) ? $this->_filterFragment($parts['fragment']) : '';

        if (isset($parts['pass'])) {
            $this->_userInfo .= ':' . $parts['pass'];
        }
    }
663816
protected function eachPageUncache($selector, callable $callback)
	{
		$num = 0;
		$id = 0;
		while (true) {
			$p = $this->pages->get("{$selector}, id>$id");
			if(!$id = $p->id) break;
			$callback($p);
			$this->pages->uncacheAll($p);
			$num++;
		}
		return $num;
	}
1195953
function displayItemSidebar(uri) {
  uri = (uri || currentURI).replace(/#.*/, '');
  exports.currentURI = currentURI = uri;
  // watchannotation
  $('.watch.annotation').click(function() {
    if (treeInterface.lastAnno) {
      $('.watch.modal').modal('show');
      $('#watchItems').val('annotation:'+treeInterface.lastAnno.flattened);
    }
  });
  $('.context.dropdown').dropdown();

  context.pubsub.item.annotations.request(uri, function(data) {
    console.log('/annotations', data);
    // update query items
    if (data.annotationSummary && lastQuery.results.hits) {
      console.log('CHECKME why would this fire?');
      var i = 0, l = lastQuery.results.hits.hits.length;
      for (i; i < l; i++) {
        if (lastQuery.results.hits.hits[i]._id === data.uri) {
          lastQuery.results.hits.hits[i]._source.annotationSummary = data.annotationSummary;
          break;
        }
      }
      updateResults(lastQuery);
    }

    if (data.uri === currentURI) {
      annoTree.display(data.annotations, data.uri, treeInterface);
    }
  });
  $('.details.sidebar').sidebar('show');
}
735631
protected function createUriPointerMap(UriInterface $uri)
    {
        $uri = clone $uri;
        $uri->normalize();
        $map = array(array($uri->toString(), array()));

        $fragmentPointer = $this->pointerFactory()->createFromUri($uri);
        if ($fragmentPointer->hasAtoms()) {
            $atoms = array();
            $fragmentlessUri = clone $uri;
            $fragmentlessUri->setFragment(null);

            while ($fragmentPointer->hasAtoms()) {
                array_unshift($atoms, $fragmentPointer->lastAtom());
                $fragmentPointer = $fragmentPointer->parent();

                $uri = clone $fragmentlessUri;
                $uri->setFragment($fragmentPointer->string());
                $uri->normalize();

                array_unshift($map, array($uri->toString(), $atoms));
            }
        }

        return $map;
    }
595527
public function gatherDebugBarDetails(array $debugBarSelectors, DocumentElement $page)
    {
        $details = '';
        foreach ($debugBarSelectors as $name => $selector) {
            $details .= '  [' . strtoupper($name) . '] ';
            if ($detailText = $page->find('css', $selector)) {
                $details .= $detailText->getText();
            } else {
                $details .= 'Element "' . $selector . '" Not Found.';
            }
            $details .= PHP_EOL;
        }
        return $details;
    }