API::inlineDocumentation PHP Method

inlineDocumentation() public method

Display the API Documentation in Html (parsed from markdown)
public inlineDocumentation ( $file )
$file string relative path of documentation file
    public function inlineDocumentation($file)
    {
        global $CFG_GLPI;
        self::header(true, __("API Documentation"));
        echo Html::css($CFG_GLPI['root_doc'] . "/lib/prism/prism.css");
        echo Html::script($CFG_GLPI['root_doc'] . "/lib/prism/prism.js");
        echo "<div class='documentation'>";
        $documentation = file_get_contents(GLPI_ROOT . '/' . $file);
        $md = new Michelf\MarkdownExtra();
        $md->code_class_prefix = "language-";
        $md->header_id_func = function ($headerName) {
            $headerName = str_replace(array('(', ')'), '', $headerName);
            return rawurlencode(strtolower(strtr($headerName, [' ' => '-'])));
        };
        echo $md->transform($documentation);
        echo "</div>";
        Html::nullFooter();
    }

Usage Example

Esempio n. 1
0
 /**
  * Display the APIRest Documentation in Html (parsed from markdown)
  *
  * @param $file    string   relative path of documentation file (default 'apirest.md')
  **/
 public function inlineDocumentation($file = "apirest.md")
 {
     global $CFG_GLPI;
     if ($this->format == "html") {
         parent::inlineDocumentation($file);
     } else {
         if ($this->format == "json") {
             echo file_get_contents(GLPI_ROOT . '/' . $file);
         }
     }
 }