function mapi_abs_path($path, $prefix = null) { if (!$path) { return null; } $path = stripslashes(preg_replace('/\\//', '', $path)); $path = preg_replace('/\\:/', '/', $path); if ($prefix && strlen($prefix) > 0) { $path = APATH . '/' . $prefix . '/' . $path . '.php'; } else { $path = APATH . '/' . $path . '.php'; } $path = realpath($path); if (mapi_check_path($path)) { return $path; } else { return null; } }
static function markdown($type, $name) { $markdown = array(); if (!in_array($type, self::$types)) { return $markdown; } $path = APATH . '/' . $type . 's/' . $name . '/' . $name . '.md'; if (!mapi_check_path($path)) { return $markdown; } $result = Parsedown::instance()->parse(file_get_contents($path)); if (!strlen($result)) { return null; } $title = mapi_html_elements_val($result, 'h1'); if (isset($title[0]) && strlen($title[0]) > 1) { $markdown['title'] = $title[0]; } $version = mapi_html_elements_val($result, 'h2'); if (isset($version[0]) && strlen($version[0]) > 1) { $markdown['version'] = $version[0]; } $description = mapi_html_elements_val($result, 'p'); if (isset($description[0]) && strlen($description[0]) > 0) { $markdown['description'] = $description[0]; } return $markdown; }