Page MenuHomePhabricator

D8061.id18242.diff
No OneTemporary

D8061.id18242.diff

Index: src/applications/phriction/config/PhabricatorPhrictionConfigOptions.php
===================================================================
--- src/applications/phriction/config/PhabricatorPhrictionConfigOptions.php
+++ src/applications/phriction/config/PhabricatorPhrictionConfigOptions.php
@@ -16,6 +16,10 @@
$this->newOption(
'metamta.phriction.subject-prefix', 'string', '[Phriction]')
->setDescription(pht("Subject prefix for Phriction email.")),
+ $this->newOption(
+ 'phriction.hierarchy-display-levels', 'int', 2)
+ ->setDescription(pht("Number of levels to display in Document "
+ ."Hierarchy - '-1' means no limit.")),
);
}
Index: src/applications/phriction/controller/PhrictionDocumentController.php
===================================================================
--- src/applications/phriction/controller/PhrictionDocumentController.php
+++ src/applications/phriction/controller/PhrictionDocumentController.php
@@ -317,23 +317,28 @@
$content_dao = new PhrictionContent();
$conn = $document_dao->establishConnection('r');
+ $depth = PhabricatorEnv::getEnvConfig('phriction.hierarchy-display-levels');
+
+ if ($depth == 0) {
+ return;
+ }
+
$limit = 250;
$d_child = PhabricatorSlug::getDepth($slug) + 1;
- $d_grandchild = PhabricatorSlug::getDepth($slug) + 2;
+ $d_total = PhabricatorSlug::getDepth($slug) + $depth;
// Select children and grandchildren.
$children = queryfx_all(
$conn,
'SELECT d.slug, d.depth, c.title FROM %T d JOIN %T c
ON d.contentID = c.id
- WHERE d.slug LIKE %> AND d.depth IN (%d, %d)
+ WHERE d.slug LIKE %> AND d.depth IN (%Ld)
AND d.status IN (%Ld)
ORDER BY d.depth, c.title LIMIT %d',
$document_dao->getTableName(),
$content_dao->getTableName(),
($slug == '/' ? '' : $slug),
- $d_child,
- $d_grandchild,
+ range($d_child, $d_total),
array(
PhrictionDocumentStatus::STATUS_EXISTS,
PhrictionDocumentStatus::STATUS_STUB,
@@ -360,7 +365,7 @@
if (count($children) == $limit) {
$more_children = true;
foreach ($children as $child) {
- if ($child['depth'] == $d_grandchild) {
+ if ($child['depth'] > $d_child) {
$more_children = false;
}
}
@@ -383,37 +388,10 @@
}
}
- // Fill in any missing children.
- $known_slugs = ipull($children, null, 'slug');
- foreach ($grandchildren as $slug => $ignored) {
- if (empty($known_slugs[$slug])) {
- $children[] = array(
- 'slug' => $slug,
- 'depth' => $d_child,
- 'title' => PhabricatorSlug::getDefaultTitle($slug),
- 'empty' => true,
- );
- }
- }
-
$children = isort($children, 'title');
- $list = array();
- foreach ($children as $child) {
- $list[] = hsprintf('<li>');
- $list[] = $this->renderChildDocumentLink($child);
- $grand = idx($grandchildren, $child['slug'], array());
- if ($grand) {
- $list[] = hsprintf('<ul>');
- foreach ($grand as $grandchild) {
- $list[] = hsprintf('<li>');
- $list[] = $this->renderChildDocumentLink($grandchild);
- $list[] = hsprintf('</li>');
- }
- $list[] = hsprintf('</ul>');
- }
- $list[] = hsprintf('</li>');
- }
+ $list = $this->renderDescendents($children, $grandchildren, $d_child);
+
if ($more_children) {
$list[] = phutil_tag('li', array(), pht('More...'));
}
@@ -439,6 +417,31 @@
->appendChild($content);
}
+ private function renderDescendents(
+ $children,
+ $grandchildren,
+ $current_depth) {
+
+ $list = array();
+ foreach ($children as $child) {
+ if ($child['depth'] != $current_depth) {
+ continue;
+ }
+ $list[] = hsprintf('<li>');
+ $list[] = $this->renderChildDocumentLink($child);
+ $grand = idx($grandchildren, $child['slug'], array());
+ if ($grand) {
+ $list[] = hsprintf('<ul>');
+ $list = array_merge($list,
+ $this->renderDescendents($grand, $grandchildren, $current_depth + 1));
+ $list[] = hsprintf('</ul>');
+ }
+ $list[] = hsprintf('</li>');
+ }
+
+ return $list;
+ }
+
private function renderChildDocumentLink(array $info) {
$title = nonempty($info['title'], pht('(Untitled Document)'));
$item = phutil_tag(

File Metadata

Mime Type
text/plain
Expires
Oct 19 2025, 5:47 AM (4 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
12674916
Default Alt Text
D8061.id18242.diff (4 KB)

Event Timeline