protected function load(SplFileInfo $file)
    {
        // File info
        $this->filename = $file->getBasename();
        $this->sourcePath = $file->getRelativePath();

        // Load the file
        $data = $file->getContents();

        list($content, $meta) = $this->splitContentMeta($data);

        // Parse meta
        $meta = Yaml::parse($meta) ?: [];

        // Parse content
        switch ($file->getExtension()) {
            case 'md':
            case 'markdown':
                $content = Markdown::parse($content);
                $this->type = self::TYPE_MARKDOWN;
                break;
            case 'tx':
            case 'textile':
                $content = Textile::parse($content);
                $this->type = self::TYPE_TEXTILE;
                break;
        }

        // Set content
        $this->content = $content;
        $this->meta = $meta;

        // Ensure local URLs are absolute
        foreach($this->meta as $key=>$value) {
            if (preg_match('/\burl\b|.*_url\b/', $key)) {
                $this->meta[$key] = $this->builder->getUrl($value);
            }
        }

        // Set target
        $this->setTarget($file);

        // Pagination enabled
        $this->paginate = isset($this->meta['paginate']);

        // Get parent page
        if ($root = dirname(dirname($this->target))) {
            if ($root !== DIRECTORY_SEPARATOR) {
                $this->parentId = ltrim($root, '/');
            }
        }

        // Set URL
        $this->url = '/' . trim(str_replace([DIRECTORY_SEPARATOR, '//'], ['/', '/'], $this->target), '/');

        // Remove "index.html" from the end, this provides a cleaner URL
        if (substr($this->url, -10) === 'index.html') {
            $this->url = substr($this->url, 0, -10);
        }

        // Set basic values
        $this->id = trim($this->url, '/') ?: 'root';
        $this->title = $this->get('title');
        $this->url = $this->builder->getUrl($this->url);

        // Set Description
        if ($this->has('description')) {
            $this->description = $this->get('description');
        }
        else {
            $this->description = $this->getDescription();
        }
    }
protected function load(SplFileInfo $file)
    {
        // File info
        $this->filename = $file->getBasename();
        $this->sourcePath = $file->getRelativePath();

        // Load the file
        $data = $file->getContents();

        list($content, $meta) = $this->splitContentMeta($data);

        // Parse meta
        $meta = Yaml::parse($meta) ?: [];

        // Parse content
        switch ($file->getExtension()) {
            case 'md':
            case 'markdown':
                $content = Markdown::parse($content);
                $this->type = self::TYPE_MARKDOWN;
                break;
            case 'tx':
            case 'textile':
                $content = Textile::parse($content);
                $this->type = self::TYPE_TEXTILE;
                break;
        }

        // Set content
        $this->content = $content;
        $this->meta = $meta;

        // Ensure local URLs are absolute
        foreach($this->meta as $key=>$value) {
            if (preg_match('/\burl\b|.*_url\b/', $key)) {
                $this->meta[$key] = $this->builder->getUrl($value);
            }
        }

        // Set target
        $this->setTarget($file);

        // Pagination enabled
        $this->paginate = isset($this->meta['paginate']);

        // Get parent page
        if ($root = dirname(dirname($this->target))) {
            if ($root !== DIRECTORY_SEPARATOR) {
                $this->parentId = ltrim($root, '/');
            }
        }

        // Set URL
        $this->url = '/' . trim(str_replace([DIRECTORY_SEPARATOR, '//'], ['/', '/'], $this->target), '/');

        // Remove "index.html" from the end, this provides a cleaner URL
        if (substr($this->url, -10) === 'index.html') {
            $this->url = substr($this->url, 0, -10);
        }

        // Set basic values
        $this->id = trim($this->url, '/') ?: 'root';
        $this->title = $this->get('title');
        $this->url = $this->builder->getUrl($this->url);

        // Set Description
        if ($this->has('description')) {
            $this->description = $this->get('description');
        }
        else {
            $this->description = $this->getDescription();
        }
    }
protected function load ( SplFileInfo $ file ) { // File info $ this -> filename = $ file -> getBasename ( ) ; $ this -> sourcePath = $ file -> getRelativePath ( ) ; // Load the file $ data = $ file -> getContents ( ) ; list ( $ content , $ meta ) = $ this -> splitContentMeta ( $ data ) ; // Parse meta $ meta = Yaml :: parse ( $ meta ) ? : [ ] ; // Parse content switch ( $ file -> getExtension ( ) ) { case 'md' : case 'markdown' : $ content = Markdown :: parse ( $ content ) ; $ this -> type = self :: TYPE_MARKDOWN ; break ; case 'tx' : case 'textile' : $ content = Textile :: parse ( $ content ) ; $ this -> type = self :: TYPE_TEXTILE ; break ; } // Set content $ this -> content = $ content ; $ this -> meta = $ meta ; // Ensure local URLs are absolute foreach ( $ this -> meta as $ key => $ value ) { if ( preg_match ( '/\burl\b|.*_url\b/' , $ key ) ) { $ this -> meta [ $ key ] = $ this -> builder -> getUrl ( $ value ) ; } } // Set target $ this -> setTarget ( $ file ) ; // Pagination enabled $ this -> paginate = isset ( $ this -> meta [ 'paginate' ] ) ; // Get parent page if ( $ root = dirname ( dirname ( $ this -> target ) ) ) { if ( $ root !== DIRECTORY_SEPARATOR ) { $ this -> parentId = ltrim ( $ root , '/' ) ; } } // Set URL $ this -> url = '/' . trim ( str_replace ( [ DIRECTORY_SEPARATOR , '//' ] , [ '/' , '/' ] , $ this -> target ) , '/' ) ; // Remove "index.html" from the end, this provides a cleaner URL if ( substr ( $ this -> url , - 10 ) === 'index.html' ) { $ this -> url = substr ( $ this -> url , 0 , - 10 ) ; } // Set basic values $ this -> id = trim ( $ this -> url , '/' ) ? : 'root' ; $ this -> title = $ this -> get ( 'title' ) ; $ this -> url = $ this -> builder -> getUrl ( $ this -> url ) ; // Set Description if ( $ this -> has ( 'description' ) ) { $ this -> description = $ this -> get ( 'description' ) ; } else { $ this -> description = $ this -> getDescription ( ) ; } }
Load and parse content from file.

@param  SplFileInfo $file
@return void
Load and parse content from file .