示例#1
0
 public function props()
 {
     if ($this->format() == 'v1') {
         return unyaml(data_directory() . '/' . $this->pth);
     } elseif ($this->format() == 'md') {
         $parser = new Mni\FrontYAML\Parser();
         $document = $parser->parse(file_get_contents(data_directory() . '/' . $this->pth));
         $yaml = $document->getYAML();
         $html = $document->getContent();
         return $yaml;
     }
 }
示例#2
0
<?php

<<<CONFIG
packages:
    - "mnapoli/front-yaml: *"
    - "symfony/yaml: ~2.6"
CONFIG;
use Symfony\Component\Yaml\Yaml;
use Mni\FronYAML\Parser;
$parser = new Mni\FrontYAML\Parser();
// parse groups.yml file
$groups = Yaml::parse(file_get_contents('./groups.yml'));
$data = 'PHP Facebook group\'s frequently asked questions is a community driven project with answers to some frequently asked questions that are located on <a href="https://github.com/wwphp-fb/php-resources">GitHub</a> for better code readability and better versioning capabilities. Please read these if you have PHP issue. You can also <a href="http://wwphp-fb.github.io/search.html">search for content</a>.<br><br>';
$index = [];
foreach ($groups as $group) {
    $data .= '<strong>' . $group['title'] . '</strong>';
    $data .= '<ul>';
    $path = realpath('./faq/' . $group['slug']);
    $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST);
    $faqs = [];
    foreach ($objects as $name => $object) {
        $document = $parser->parse(file_get_contents($name));
        if ($object->isFile()) {
            $yaml = $document->getYAML();
            $faqs[$name] = ['title' => $yaml['title'], 'link' => 'http://wwphp-fb.github.io' . $yaml['permalink'], 'updated' => '', 'body' => ''];
        }
    }
    ksort($faqs);
    foreach ($faqs as $faq) {
        $data .= '<li><a href="' . $faq['link'] . '">' . $faq['title'] . '</a></li>';
        $index[] = ["title" => $faq['title'], "url" => $faq['link'], "date" => $faq['updated'], "body" => $faq['body'], "categories" => []];