コード例 #1
0
 /**
  * @dataProvider fullProvider
  */
 public function testFullUsingString($base)
 {
     $data = file_get_contents(DATA_DIR . DIRECTORY_SEPARATOR . $base . '.readme');
     $expected = unserialize(file_get_contents(DATA_DIR . DIRECTORY_SEPARATOR . $base . '.ser'));
     $data = Baikonur_ReadmeParser::parse_readme_contents($data);
     $this->assertEquals($expected, $data);
 }
コード例 #2
0
 public static function parse_readme_contents($contents)
 {
     if (empty($contents)) {
         return array();
     }
     $result = parent::parse_readme_contents($contents);
     foreach ($result->sections as &$section) {
         $section = self::filter_text($section);
     }
     if (!empty($result->upgrade_notice)) {
         foreach ($result->upgrade_notice as &$notice) {
             $notice = self::sanitize_text($notice);
         }
     }
     if (!empty($result->screenshots)) {
         foreach ($result->screenshots as &$shot) {
             $shot = self::filter_text($shot);
         }
     }
     if (!empty($result->remaining_content)) {
         $result->remaining_content = implode("\n", $result->remaining_content);
         $result->remaining_content = self::filter_text(str_replace("</h3>\n\n", "</h3>\n", $result->remaining_content));
     } else {
         $result->remaining_content = '';
     }
     $result->name = self::sanitize_text($result->name);
     //$result->short_description = self::sanitize_text($result->short_description);
     $result->donate_link = esc_url($result->donate_link);
     $result->requires_at_least = $result->requires;
     $result->tested_up_to = $result->tested;
     unset($result->requires, $result->tested);
     $result = (array) $result;
     return $result;
 }