indiana-university/iukb-api-doc-content-php

一个用于简化知识库内容展示的类

v1.5 2021-10-18 17:15 UTC

This package is auto-updated.

Last update: 2024-09-15 01:11:43 UTC


README

一个用于简化知识库内容展示的类

要求

  • indiana-university/iukb-api-php

使用方法

使用方法很简单,你只需在工厂类上静态调用 create 方法。

基础知识

use Edu\Iu\Uits\KnowledgeBase\Document\ContentFactory;

$doc = $kb->getDocument('amyk');
$content = ContentFactory::create($doc->getContent());
echo $content->getBody();

链接

知识库返回的链接可能不适用于您的使用。为了修改它们,提供了一个 'rebase' 函数。这将允许您更改四个字符文档 ID 之前的部分。

use Edu\Iu\Uits\KnowledgeBase\Document\ContentFactory;

$doc = $kb->getDocument('amyk');
$content = ContentFactory::create($doc->getContent());

// If the hrefs are simply the doc id but need to be /help/docid
$content->rebaseKbLinks('', '/help/');

// If the links are full urls to the KB but need to be /help/docid
$content->rebaseKbLinks('https://kb.iu.edu/d/', '/help/');

Rivet 样式

目前知识库使用自定义的 Bootstrap 主题,因此类名遵循 Bootstrap 名称。这与 Rivet 不兼容。如果您希望使用 Rivet 样式显示文档,可以简单地使用 rivetize() 函数。

此函数基于印第安纳大学官方的 "rivetizer" JavaScript 库。有关 Rivetizer 的更多信息,请访问 https://github.com/indiana-university/rivetizer

use Edu\Iu\Uits\KnowledgeBase\Document\ContentFactory;

$doc = $kb->getDocument('amyk');
$content = ContentFactory::create($doc->getContent());
$content->rivetize();

贡献

欢迎以 GitHub pull request 的形式贡献。请注意,为了保持一致性,请在您希望贡献给此项目的任何代码上运行 composer checkcomposer run-tests,并修复和解决发现的任何问题。