parent_id !== null) { $a = "parent post"; $page->add_block(new Block(null, "This post belongs to a $a.", "main", 5, "ImageHasParent")); } if (bool_escape($image->has_children)) { $ids = $database->get_col("SELECT id FROM images WHERE parent_id = :iid", ["iid"=>$image->id]); $html = "This post has ".(count($ids) > 1 ? "child posts" : "a child post").""; $html .= " (post "; foreach ($ids as $id) { $html .= "#{$id}, "; } $html = rtrim($html, ", ").")."; $page->add_block(new Block(null, $html, "main", 6, "ImageHasChildren")); } } public function get_parent_editor_html(Image $image): string { global $user; $h_parent_id = $image->parent_id; $s_parent_id = $h_parent_id ?: "None"; $html = "\n". " Parent\n". " \n". ( !$user->is_anonymous() ? " {$s_parent_id}\n". " \n" : $s_parent_id ). " \n". "\n"; return $html; } public function get_help_html(): string { return '

Search for posts that have parent/child relationships.

parent=any

Returns posts that have a parent.

parent=none

Returns posts that have no parent.

parent=123

Returns posts that have image 123 set as parent.

child=any

Returns posts that have at least 1 child.

child=none

Returns posts that have no children.

'; } }