api.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. use yii\apidoc\templates\bootstrap\ApiRenderer;
  3. use yii\apidoc\templates\bootstrap\SideNavWidget;
  4. use yii\helpers\StringHelper;
  5. /* @var $this yii\web\View */
  6. /* @var $types array */
  7. /* @var $content string */
  8. /** @var $renderer ApiRenderer */
  9. $renderer = $this->context;
  10. $this->beginContent('@yii/apidoc/templates/bootstrap/layouts/main.php', isset($type) ? ['type' => $type] : []); ?>
  11. <div class="row">
  12. <div class="col-md-3">
  13. <?php
  14. $types = $renderer->getNavTypes(isset($type) ? $type : null, $types);
  15. ksort($types);
  16. $nav = [];
  17. foreach ($types as $i => $class) {
  18. $namespace = $class->namespace;
  19. if (empty($namespace)) {
  20. $namespace = 'Not namespaced classes';
  21. }
  22. if (!isset($nav[$namespace])) {
  23. $nav[$namespace] = [
  24. 'label' => $namespace,
  25. 'url' => '#',
  26. 'items' => [],
  27. ];
  28. }
  29. $nav[$namespace]['items'][] = [
  30. 'label' => StringHelper::basename($class->name),
  31. 'url' => './' . $renderer->generateApiUrl($class->name),
  32. 'active' => isset($type) && ($class->name == $type->name),
  33. ];
  34. } ?>
  35. <?= SideNavWidget::widget([
  36. 'id' => 'navigation',
  37. 'items' => $nav,
  38. 'view' => $this,
  39. ])?>
  40. </div>
  41. <div class="col-md-9 api-content" role="main">
  42. <?= $content ?>
  43. </div>
  44. </div>
  45. <script type="text/javascript">
  46. /*<![CDATA[*/
  47. $("a.toggle").on('click', function () {
  48. var $this = $(this);
  49. if ($this.hasClass('properties-hidden')) {
  50. $this.text($this.text().replace(/Show/,'Hide'));
  51. $this.parents(".summary").find(".inherited").show();
  52. $this.removeClass('properties-hidden');
  53. } else {
  54. $this.text($this.text().replace(/Hide/,'Show'));
  55. $this.parents(".summary").find(".inherited").hide();
  56. $this.addClass('properties-hidden');
  57. }
  58. return false;
  59. });
  60. /*
  61. $(".sourceCode a.show").toggle(function () {
  62. $(this).text($(this).text().replace(/show/,'hide'));
  63. $(this).parents(".sourceCode").find("div.code").show();
  64. },function () {
  65. $(this).text($(this).text().replace(/hide/,'show'));
  66. $(this).parents(".sourceCode").find("div.code").hide();
  67. });
  68. $("a.sourceLink").click(function () {
  69. $(this).attr('target','_blank');
  70. });
  71. */
  72. /*]]>*/
  73. </script>
  74. <?php $this->endContent(); ?>