Generate ToC from directory structure, containing url, title and filename
of each page.

@return array as table of content.
542883
public function createTableOfContent()
    {
        $basepath   = $this->config['basepath'];
        $pattern    = $this->config['pattern'];
        $route      = $this->di->request->getRoute();

        // if dir, add index if file exists.
        // partly for adding doc/index to work
        // partly to make doc/ generate proper toc.
        $baseroute  = dirname($route);
        $path       = $basepath . '/' . $baseroute . '/' . $pattern;

        $toc = [];
        foreach (glob($path) as $file) {
            $parts    = pathinfo($file);
            $filename = $parts['filename'];

            $title = $this->getTitleFromFirstLine($file);
            $file2route = substr($filename, strpos($filename, '_') + 1);

            $url = $baseroute . '/' . $file2route;
            /*
            if ($file2route == 'index' ) {
                $url = $baseroute;
            }*/

            // Create level depending on the file id
            $id = substr($filename, 0, strpos($filename, '_'));
            $level = 2;
            if ($id % 100 === 0) {
                $level = 0;
            } elseif ($id % 10 === 0) {
                $level = 1;
            }

            $toc[$url] = [
                'title'     => $title,
                'filename'  => $parts['basename'],
                'level'     => $level,
            ];
        }

        return $toc;
    }
524008
protected function getFileContents()
    {
        $json = file_get_contents( $this->sessionPath );

        $this->items = json_decode( $json, TRUE );
    }
43952
protected function generateCatalog()
    {
        $catalog = $this->allWarehouseContent();
        $catalog = array_filter($catalog, 'is_file');
        $catalog = array_combine($catalog, $catalog);
        $catalog = array_map([$this, 'toBasePath'], $catalog);

        return $catalog;
    }
299559
public function getContents()
    {
        if (self::SCHEME_RESOURCE === $this->getScheme()) {
            $contents = '';
            while ($data = fread($this->stream, 2048)) {
                $contents .= $data;
            }
        } else {
            $contents = file_get_contents($this->uri);
        }
        return $contents;
    }
619553
public function getContents()
    {
        $file = $this->getPath();

        // Get an unserialize
        $configuration = file_get_contents($file);
        $configuration = unserialize($configuration);

        return $configuration;
    }
632752
public function GetConfigFileContents()
	{
		if (!$this->configFileContents)
		{
			// get rid of windows-style carriage returns
			$this->configFileContents = str_replace("\r\n", "\n", file_get_contents($this->configFilePath) );
		}
		
		return $this->configFileContents;
	}
839064
public function getPages(): array
    {
        if ($this->_pages !== null) {
            return $this->_pages;
        }

        $this->_pages = [];
        $pages = explode('<!--pagebreak-->', (string)$this);

        foreach ($pages as $page) {
            $this->_pages[] = new \Twig_Markup($page, Craft::$app->charset);
        }

        return $this->_pages;
    }
1353502
private function _buildDirectory()
    {
        // Vars
        $fields = array();
        $directory = array();
        $data_end = 0;

        foreach ($this->fields as $field) {
            // No empty fields allowed
            if (!$field->isEmpty()) {
                // Get data in raw format
                $str = $field->toRaw();
                $fields[] = $str;

                // Create directory entry
                $len = strlen($str);
                $direntry = sprintf("%03s%04d%05d", $field->getTag(), $len, $data_end);
                $directory[] = $direntry;
                $data_end += $len;
            }
        }

        /**
         * Rules from MARC::Record::USMARC
         */
        $base_address
            = File_MARC::LEADER_LEN +    // better be 24
                (count($directory) * File_MARC::DIRECTORY_ENTRY_LEN) +
                                // all the directory entries
                1;              // end-of-field marker


        $total
            = $base_address +  // stuff before first field
                $data_end +      // Length of the fields
                1;              // End-of-record marker


        return array($fields, $directory, $total, $base_address);
    }
929665
public function generateRoutes()
    {
        if (!$content = $this->getRoutesContent()) {
            return '';
        }

        if (version_compare(app()->version(), '5.3.0', '<')) {
            $path = app_path('Http/routes/'.implode('/', $this->sectionSegments).'.php');
        } else {
            $path = base_path('routes/web/'.implode('/', $this->sectionSegments).'.php');
        }

        if (is_file($path)) {
            return '';
        }

        $this->createMissingDirs($path);

        return file_put_contents($path, $content) !== false ? $path : '';
    }
467149
public function getHtmlContents() {
        $return_collection = new \Doctrine\Common\Collections\ArrayCollection($this->getPageContents()->filter(function ($pageContents) {
                    return get_class($pageContents->getContent()) == "Haven\CmsBundle\Entity\HtmlContent";
                })->getValues());

        return $return_collection;
    }
797354
public function getContent()
    {
        $page = $this->getPage();
        $html = $page->getHTML();
        $html = $this->replaceChildrenCalls($html);

        return $html;
    }
1322132
public function listContent()
    {
        $filesList = array();
        $numFiles = $this->archive->numFiles;
        for ($i = 0; $i < $numFiles; $i++) {
            $statIndex = $this->archive->statIndex($i);
            $filesList[] = (object) array(
                'filename' => $statIndex['name'],
                'stored_filename' => $statIndex['name'],
                'size' => $statIndex['size'],
                'compressed_size' => $statIndex['comp_size'],
                'mtime' => $statIndex,
                'comment' => ($comment = $this->archive->getCommentIndex
                    ($statIndex['index']) !== false) ? $comment : null,
                'folder' => in_array(substr($statIndex['name'], -1),
                    array('/', '\\')),
                'index' => $statIndex['index'],
                'status' => 'ok',
            );
        }

        return $filesList;
    }
560207
public function buildContent()
    {
        $contents = $this->contents;
        array_unshift( $contents, '#boundary start ' . $this->getBoundary() );
        array_push(    $contents, '#boundary end ' . $this->getBoundary() );
        return $contents;
    }
670761
public function getContent()
    {
        $params = $this->getData();
        $p = [];
        foreach ($params as $name => $value) {
            $p['{' . $name . '}'] = $value;
        }
        return strtr($this->getTemplate(), $p);
    }
768883
private function getContentMenuItems(): array
    {
        $menuItems = [];

        $rootContentId = $this->configResolver->getParameter('location_ids.content_structure');
        $rootMediaId = $this->configResolver->getParameter('location_ids.media');

        $contentStructureItem = $this->factory->createLocationMenuItem(
            self::ITEM_CONTENT__CONTENT_STRUCTURE,
            $rootContentId,
            [
                'label' => self::ITEM_CONTENT__CONTENT_STRUCTURE,
                'extras' => [
                    'routes' => [
                        'search' => 'ezplatform.search',
                        'trash' => 'ezplatform.trash.list',
                        'bookmark' => 'ezplatform.bookmark.list',
                    ],
                ],
            ]
        );
        $mediaItem = $this->factory->createLocationMenuItem(
            self::ITEM_CONTENT__MEDIA,
            $rootMediaId,
            ['label' => self::ITEM_CONTENT__MEDIA]
        );
        $linkManagerItem = $this->createLinkManagerMenuItem();

        if (null !== $contentStructureItem) {
            $menuItems[$contentStructureItem->getName()] = $contentStructureItem;
        }

        if (null !== $mediaItem) {
            $menuItems[$mediaItem->getName()] = $mediaItem;
        }

        if (null !== $linkManagerItem) {
            $menuItems[$linkManagerItem->getName()] = $linkManagerItem;
        }

        return $menuItems;
    }
658470
public function getContents()
    {
        $content = '';
        while(!$this->streamable->isEOF()) {
            $r = $this->streamable->read(1024);
            if ($r == null)
                break;

            $content .= $r;
        }
        
        return $content;
    }
172018
public function findPages(): array
    {
        $foundPages = [];
        $root = $this->getPagesPath();

        if ($root) {
            $root .=  '/';

            foreach ($this->generatePageFiles($root) as $file) {
                $slug = $this->getSlug($root, $file);
                $foundPages[$slug] = (object)[
                    'info'=> $file,
                    'content' => $this->buildContentFunction($file),
                    'slug' => $slug,
                    'depth' => count(explode('/', $slug)),
                ];
            }
        }

        return $foundPages;
    }