Generate the HTML content of this block.

@param Tree     $tree
@param int      $block_id
@param string   $ctype
@param string[] $cfg

@return string
335373
public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
    {
        $statistics = app(Statistics::class);

        $show_last_update     = $this->getBlockSetting($block_id, 'show_last_update', '1');
        $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
        $number_of_surnames   = (int) $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES);
        $stat_indi            = $this->getBlockSetting($block_id, 'stat_indi', '1');
        $stat_fam             = $this->getBlockSetting($block_id, 'stat_fam', '1');
        $stat_sour            = $this->getBlockSetting($block_id, 'stat_sour', '1');
        $stat_media           = $this->getBlockSetting($block_id, 'stat_media', '1');
        $stat_repo            = $this->getBlockSetting($block_id, 'stat_repo', '1');
        $stat_surname         = $this->getBlockSetting($block_id, 'stat_surname', '1');
        $stat_events          = $this->getBlockSetting($block_id, 'stat_events', '1');
        $stat_users           = $this->getBlockSetting($block_id, 'stat_users', '1');
        $stat_first_birth     = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
        $stat_last_birth      = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
        $stat_first_death     = $this->getBlockSetting($block_id, 'stat_first_death', '1');
        $stat_last_death      = $this->getBlockSetting($block_id, 'stat_last_death', '1');
        $stat_long_life       = $this->getBlockSetting($block_id, 'stat_long_life', '1');
        $stat_avg_life        = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
        $stat_most_chil       = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
        $stat_avg_chil        = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');

        extract($cfg, EXTR_OVERWRITE);

        if ($show_common_surnames) {
            // Use the count of base surnames.
            $top_surnames = DB::table('name')
                ->where('n_file', '=', $tree->id())
                ->where('n_type', '<>', '_MARNM')
                ->whereNotIn('n_surn', ['@N.N.', ''])
                ->groupBy('n_surn')
                ->orderByDesc(DB::raw('COUNT(n_surn)'))
                ->take($number_of_surnames)
                ->pluck('n_surn');

            $all_surnames = [];

            foreach ($top_surnames as $top_surname) {
                $variants = DB::table('name')
                    ->where('n_file', '=', $tree->id())
                    ->where(DB::raw('n_surn /*! COLLATE utf8_bin */'), '=', $top_surname)
                    ->groupBy('surname')
                    ->select([DB::raw('n_surname /*! COLLATE utf8_bin */ AS surname'), DB::raw('count(*) AS total')])
                    ->pluck('total', 'surname')
                    ->all();

                $all_surnames[$top_surname] = $variants;
            }

            uksort($all_surnames, [I18N::class, 'strcasecmp']);

            //find a module providing individual lists
            $module = app(ModuleService::class)->findByComponent(ModuleListInterface::class, $tree, Auth::user())->first(static function (ModuleInterface $module) {
                return $module instanceof IndividualListModule;
            });
            
            $surnames = FunctionsPrintLists::surnameList($all_surnames, 2, false, $module, $tree);
        } else {
            $surnames = '';
        }

        $content = view('modules/gedcom_stats/statistics', [
            'show_last_update'     => $show_last_update,
            'show_common_surnames' => $show_common_surnames,
            'number_of_surnames'   => $number_of_surnames,
            'stat_indi'            => $stat_indi,
            'stat_fam'             => $stat_fam,
            'stat_sour'            => $stat_sour,
            'stat_media'           => $stat_media,
            'stat_repo'            => $stat_repo,
            'stat_surname'         => $stat_surname,
            'stat_events'          => $stat_events,
            'stat_users'           => $stat_users,
            'stat_first_birth'     => $stat_first_birth,
            'stat_last_birth'      => $stat_last_birth,
            'stat_first_death'     => $stat_first_death,
            'stat_last_death'      => $stat_last_death,
            'stat_long_life'       => $stat_long_life,
            'stat_avg_life'        => $stat_avg_life,
            'stat_most_chil'       => $stat_most_chil,
            'stat_avg_chil'        => $stat_avg_chil,
            'stats'                => $statistics,
            'surnames'             => $surnames,
        ]);

        if ($ctype !== '') {
            if ($ctype === 'gedcom' && Auth::isManager($tree)) {
                $config_url = route('tree-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } elseif ($ctype === 'user' && Auth::check()) {
                $config_url = route('user-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } else {
                $config_url = '';
            }

            return view('modules/block-template', [
                'block'      => Str::kebab($this->name()),
                'id'         => $block_id,
                'config_url' => $config_url,
                'title'      => $this->title(),
                'content'    => $content,
            ]);
        }

        return $content;
    }
469039
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $num       = $this->getBlockSetting($block_id, 'num', self::DEFAULT_NUMBER);
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_STYLE);

        $info_styles = [
            /* I18N: An option in a list-box */
            'list'     => I18N::translate('bullet list'),
            /* I18N: An option in a list-box */
            'array'    => I18N::translate('compact list'),
            /* I18N: An option in a list-box */
            'table'    => I18N::translate('table'),
            /* I18N: An option in a list-box */
            'tagcloud' => I18N::translate('tag cloud'),
        ];

        echo view('modules/top10_surnames/config', [
            'num'         => $num,
            'infoStyle'   => $infoStyle,
            'info_styles' => $info_styles,
        ]);
    }
981342
public function render_assign_files(assign_files $tree) {
        $this->htmlid = html_writer::random_id('assign_files_tree');
        $this->page->requires->js_init_call('M.mod_assign.init_tree', array(true, $this->htmlid));
        $html = '<div id="'.$this->htmlid.'">';
        $html .= $this->htmllize_tree($tree, $tree->dir);
        $html .= '</div>';

        if ($tree->portfolioform) {
            $html .= $tree->portfolioform;
        }
        return $html;
    }
151281
private function _generateJs($treeId)
    {
        $id = $this->getOption('id');
        $treeClearId = $treeId . '_clear';
        $view = \Mmi\App\FrontController::getInstance()->getView();
        $view->headScript()->appendScript("$(document).ready(function () {
				$('#$treeId').jstree({
					'core': {
						'themes': {
							'name': 'default',
							'variant': 'small',
							'responsive' : true,
							'stripes' : true
						},
						'multiple': " . ($this->getOption('multiple') ? 'true' : 'false') . ",
						'expand_selected_onload': true,
						'check_callback' : false
					}
				})
				.on('changed.jstree', function (e, data) {
					var selectedStr = '';
					if (0 in data.selected) {
						selectedStr = data.selected[0];
					}
					for (idx = 1, len = data.selected.length; idx < len; ++idx) {
						selectedStr = selectedStr.concat(';' + data.selected[idx])
					}
					$('#$id').val(selectedStr);
				});
				$('#$treeClearId').click(function () {
					$('#$id').val('');
					$('#$treeId').jstree('deselect_all');
				});
			});
		");
    }
736587
private function renderNode(NodeInterface $node, int $node_id): string
    {
        if ($node instanceof LeafNode) {
            return $this->renderLeafNode($node, $node_id);
        } elseif ($node instanceof RootNode) {
            return $this->renderRootNode($node_id);
        }
        return $this->renderInternalNode($node, $node_id);
    }
450715
private function recursiveBuildFinalBlockTree(BlockInterface $block = null, BlockView $view, &$output = null)
    {
        $viewHash = spl_object_hash($view);
        $blockHash = null;

        if (null !== $block) {
            $blockHash = spl_object_hash($block);
        } elseif (isset($this->blocksByView[$viewHash])) {
            $blockHash = $this->blocksByView[$viewHash];
        }

        $output = isset($this->dataByView[$viewHash])
            ? $this->dataByView[$viewHash]
            : [];

        if (null !== $blockHash) {
            $output = array_replace(
                $output,
                isset($this->dataByBlock[$blockHash])
                    ? $this->dataByBlock[$blockHash]
                    : []
            );
        }

        $this->validateViewIds($block, $view);

        $output['children'] = [];

        foreach ($view->children as $name => $childView) {
            // The CSRF token, for example, is never added to the block tree.
            // It is only present in the view.
            $childBlock = null !== $block && $block->has($name)
                ? $block->get($name)
                : null;

            $childHash = spl_object_hash($childView);
            $output['children'][$childHash] = [];

            $this->recursiveBuildFinalBlockTree($childBlock, $childView, $output['children'][$childHash]);
        }
    }
1280813
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $title          = $this->getBlockSetting($block_id, 'title', '');
        $html           = $this->getBlockSetting($block_id, 'html', '');
        $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
        $languages      = explode(',', $this->getBlockSetting($block_id, 'languages'));
        $all_trees      = Tree::getNameList();

        $templates = [
            $html                                    => I18N::translate('Custom'),
            view('modules/html/template-keywords')   => I18N::translate('Keyword examples'),
            view('modules/html/template-narrative')  => I18N::translate('Narrative description'),
            view('modules/html/template-statistics') => I18N::translate('Statistics'),
        ];

        echo view('modules/html/config', [
            'all_trees'      => $all_trees,
            'html'           => $html,
            'languages'      => $languages,
            'show_timestamp' => $show_timestamp,
            'templates'      => $templates,
            'title'          => $title,
        ]);
    }
827476
public void generateTreeFile() throws IOException {
        HtmlTree body = getTreeHeader();
        Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
                HtmlStyle.title, headContent);
        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
        addPackageTreeLinks(div);
        HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
                ? HtmlTree.MAIN()
                : body;
        htmlTree.addContent(div);
        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
        divTree.addStyle(HtmlStyle.contentContainer);
        addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree);
        addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree);
        addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
        addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree);
        htmlTree.addContent(divTree);
        if (configuration.allowTag(HtmlTag.MAIN)) {
            body.addContent(htmlTree);
        }
        if (configuration.allowTag(HtmlTag.FOOTER)) {
            htmlTree = HtmlTree.FOOTER();
        } else {
            htmlTree = body;
        }
        addNavLinks(false, htmlTree);
        addBottom(htmlTree);
        if (configuration.allowTag(HtmlTag.FOOTER)) {
            body.addContent(htmlTree);
        }
        printHtmlDocument(null, true, body);
    }
1280931
function (cfg, ctxt) {
        this.$BaseWidget.constructor.apply(this, arguments);

        /**
         * Creates a unique id to be used in the markup generated by the widget.
         * @return {String}
         */
        if (!cfg.id) {
            this._domId = this._createDynamicId();
        } else {
            this._domId = this._context.$getId(cfg.id);
        }

        /**
         * Element containing the template content
         * @protected
         * @type HTMLElement
         */
        this._subTplDiv = null;

        /**
         * Template context of the sub template.
         * @type aria.templates.TemplateCtxt
         */
        this.subTplCtxt = null;

        /**
         * Is true if a module controller instance has to be created by the template widget itself.
         * @protected
         * @type Boolean
         */
        this._needCreatingModuleCtrl = cfg.moduleCtrl && cfg.moduleCtrl.getData == null;

        /**
         * Configuration which will be sent to the template context. It is initialized with some properties in the
         * template widget constructor and completed later. It is set to null just after the template context has been
         * initialized, or if an error prevents the template from being loaded. So, if it is not null, we are still
         * waiting for the template to be loaded.
         * @protected
         * @type aria.templates.CfgBeans:InitTemplateCfg
         */
        this._tplcfg = {
            classpath : ariaCoreEnvironmentCustomizations.getTemplateCP(cfg.classpath),
            args : cfg.args,
            id : this._domId,
            moduleCtrl : cfg.moduleCtrl
        };
        // does the normalization
        this._checkCfgConsistency(cfg);

        var tplCtxt = new ariaTemplatesTemplateCtxt();
        this.subTplCtxt = tplCtxt;

        /**
         * Whether the context was already initialized or not.<br />
         * Not-initialized context means the the widget is still waiting for some dependencies to load, thus it's a
         * differed content
         * @type Boolean
         * @protected
         */
        this._initCtxDone = false;

        /**
         * Whether or not the widget is differed in its main section.<br />
         * If the context is not initialized when the markup is created this widget should be considered as differed to
         * avoid triggering $displayReady on the containg template
         * @type Boolean
         * @override
         */
        this.isDiffered = false;

        /**
         * CSS classes coming from the CSS templates associated to the template
         * @protected
         * @type String
         */
        this._cssClassNames = "";
    }
170041
private function treeBlock(ServerRequestInterface $request, Tree $tree, UserInterface $user): ModuleBlockInterface
    {
        $block_id = (int) $request->get('block_id');

        $block = DB::table('block')
            ->where('block_id', '=', $block_id)
            ->where('gedcom_id', '=', $tree->id())
            ->whereNull('user_id')
            ->first();

        if ($block === null) {
            throw new NotFoundHttpException();
        }

        $module = $this->module_service->findByName($block->module_name);

        if (!$module instanceof ModuleBlockInterface) {
            throw new NotFoundHttpException();
        }

        if ($block->user_id !== $user->id() && !Auth::isAdmin()) {
            throw new AccessDeniedHttpException();
        }

        return $module;
    }
80080
public function buildTreeHtml($keys = [], $items = [], $config = [], $selected = []) {
        $configDefault = [
            'id' => 'nestable',
            'class' => 'dd',
            'containerClass' => 'dd-list',
            'itemClass' => 'dd-item',
            'labelClass' => 'dd-handle',
            'actions' => [],
        ];
        $config = array_merge($configDefault, $config);

        // root items
        $asRoot = false;
        if (empty($items)) {
            $asRoot = true;
            $items[] = [
                '_id' => $this->owner->getAttribute('_id'),
                'name' => $this->owner->getAttribute('name'),
                'lft' => $this->owner->getAttribute($this->leftAttribute),
                'rgt' => $this->owner->getAttribute($this->rightAttribute),
            ];
            $children = $this->children()->all();
            foreach ($children as $child) {
                $items[] = [
                    '_id' => $child->owner->getAttribute('_id'),
                    'name' => $child->owner->getAttribute('name'),
                    $this->leftAttribute => $child->owner->getAttribute($this->leftAttribute),
                    $this->rightAttribute => $child->owner->getAttribute($this->rightAttribute),
                ];
            }
            $keys = $this->buildTreeKeys($items);
        }
        
        $list = Html::beginTag('ol', ['class' => $config['containerClass']]);
        foreach ($keys as $key => $row) {
            if (isset($config['actions'])) {
                $actions = str_replace ('{_id}', $items[$key]['_id'], $config['actions']);

                if (is_array($selected) && in_array($items[$key]['_id'], $selected)) {
                    $actions = str_replace ('{check}', 'checked', $actions);
                }
            }

            if (count($row)) {
                $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name']  . '</div>' . $this->buildTreeHtml($row, $items, $config, $selected), ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]);
            } else {
                $list .= Html::tag('li', $actions.'<div class="' . $config['labelClass'] . '">' . $items[$key]['name'] . '</div>', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']]);
            }
        }
        $list .= Html::endTag('ol');

//        if (strpos($list, Html::beginTag('li', ['class' => $config['itemClass'], 'data-id' => $items[$key]['_id']])) === false) {
//            $list = '';
//        }
        
        if ($asRoot){
            $list = Html::tag('div', $list, ['id' => $config['id'], 'class' => $config['class']]);
        }
        return $list;
    }
483437
function apply_styles(FrameTree $tree)
    {
        // Use XPath to select nodes.  This would be easier if we could attach
        // Frame objects directly to DOMNodes using the setUserData() method, but
        // we can't do that just yet.  Instead, we set a _node attribute_ in
        // Frame->set_id() and use that as a handle on the Frame object via
        // FrameTree::$_registry.

        // We create a scratch array of styles indexed by frame id.  Once all
        // styles have been assigned, we order the cached styles by specificity
        // and create a final style object to assign to the frame.

        // FIXME: this is not particularly robust...

        $styles = array();
        $xp = new DOMXPath($tree->get_dom());
        $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();

        // Add generated content
        foreach ($this->_styles as $selector => $selector_styles) {
            /** @var Style $style */
            foreach ($selector_styles as $style) {
                if (strpos($selector, ":before") === false && strpos($selector, ":after") === false) {
                    continue;
                }

                $query = $this->_css_selector_to_xpath($selector, true);

                // Retrieve the nodes, limit to body for generated content
                //TODO: If we use a context node can we remove the leading dot?
                $nodes = @$xp->query('.' . $query["query"]);
                if ($nodes == null) {
                    Helpers::record_warnings(E_USER_WARNING, "The CSS selector '$selector' is not valid", __FILE__, __LINE__);
                    continue;
                }

                /** @var \DOMElement $node */
                foreach ($nodes as $node) {
                    // Only DOMElements get styles
                    if ($node->nodeType != XML_ELEMENT_NODE) {
                        continue;
                    }

                    foreach (array_keys($query["pseudo_elements"], true, true) as $pos) {
                        // Do not add a new pseudo element if another one already matched
                        if ($node->hasAttribute("dompdf_{$pos}_frame_id")) {
                            continue;
                        }

                        if (($src = $this->_image($style->get_prop('content'))) !== "none") {
                            $new_node = $node->ownerDocument->createElement("img_generated");
                            $new_node->setAttribute("src", $src);
                        } else {
                            $new_node = $node->ownerDocument->createElement("dompdf_generated");
                        }

                        $new_node->setAttribute($pos, $pos);
                        $new_frame_id = $tree->insert_node($node, $new_node, $pos);
                        $node->setAttribute("dompdf_{$pos}_frame_id", $new_frame_id);
                    }
                }
            }
        }

        // Apply all styles in stylesheet
        foreach ($this->_styles as $selector => $selector_styles) {
            /** @var Style $style */
            foreach ($selector_styles as $style) {
                $query = $this->_css_selector_to_xpath($selector);

                // Retrieve the nodes
                $nodes = @$xp->query($query["query"]);
                if ($nodes == null) {
                    Helpers::record_warnings(E_USER_WARNING, "The CSS selector '$selector' is not valid", __FILE__, __LINE__);
                    continue;
                }

                $spec = $this->_specificity($selector, $style->get_origin());

                foreach ($nodes as $node) {
                    // Retrieve the node id
                    // Only DOMElements get styles
                    if ($node->nodeType != XML_ELEMENT_NODE) {
                        continue;
                    }

                    $id = $node->getAttribute("frame_id");

                    // Assign the current style to the scratch array
                    $styles[$id][$spec][] = $style;
                }
            }
        }

        // Set the page width, height, and orientation based on the canvas paper size
        $canvas = $this->_dompdf->getCanvas();
        $paper_width = $canvas->get_width();
        $paper_height = $canvas->get_height();
        $paper_orientation = ($paper_width > $paper_height ? "landscape" : "portrait");

        if ($this->_page_styles["base"] && is_array($this->_page_styles["base"]->size)) {
            $paper_width = $this->_page_styles['base']->size[0];
            $paper_height = $this->_page_styles['base']->size[1];
            $paper_orientation = ($paper_width > $paper_height ? "landscape" : "portrait");
        }

        // Now create the styles and assign them to the appropriate frames. (We
        // iterate over the tree using an implicit FrameTree iterator.)
        $root_flg = false;
        foreach ($tree->get_frames() as $frame) {
            // Helpers::pre_r($frame->get_node()->nodeName . ":");
            if (!$root_flg && $this->_page_styles["base"]) {
                $style = $this->_page_styles["base"];
            } else {
                $style = $this->create_style();
            }

            // Find nearest DOMElement parent
            $p = $frame;
            while ($p = $p->get_parent()) {
                if ($p->get_node()->nodeType == XML_ELEMENT_NODE) {
                    break;
                }
            }

            // Styles can only be applied directly to DOMElements; anonymous
            // frames inherit from their parent
            if ($frame->get_node()->nodeType != XML_ELEMENT_NODE) {
                if ($p) {
                    $style->inherit($p->get_style());
                }

                $frame->set_style($style);
                continue;
            }

            $id = $frame->get_id();

            // Handle HTML 4.0 attributes
            AttributeTranslator::translate_attributes($frame);
            if (($str = $frame->get_node()->getAttribute(AttributeTranslator::$_style_attr)) !== "") {
                $styles[$id][self::SPEC_NON_CSS][] = $this->_parse_properties($str);
            }

            // Locate any additional style attributes
            if (($str = $frame->get_node()->getAttribute("style")) !== "") {
                // Destroy CSS comments
                $str = preg_replace("'/\*.*?\*/'si", "", $str);

                $spec = $this->_specificity("!attr", self::ORIG_AUTHOR);
                $styles[$id][$spec][] = $this->_parse_properties($str);
            }

            // Grab the applicable styles
            if (isset($styles[$id])) {

                /** @var array[][] $applied_styles */
                $applied_styles = $styles[$frame->get_id()];

                // Sort by specificity
                ksort($applied_styles);

                if ($DEBUGCSS) {
                    $debug_nodename = $frame->get_node()->nodeName;
                    print "<pre>\n[$debug_nodename\n";
                    foreach ($applied_styles as $spec => $arr) {
                        printf("specificity: 0x%08x\n", $spec);
                        /** @var Style $s */
                        foreach ($arr as $s) {
                            print "[\n";
                            $s->debug_print();
                            print "]\n";
                        }
                    }
                }

                // Merge the new styles with the inherited styles
                $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES;
                $acceptedmedia[] = $this->_dompdf->getOptions()->getDefaultMediaType();
                foreach ($applied_styles as $arr) {
                    /** @var Style $s */
                    foreach ($arr as $s) {
                        $media_queries = $s->get_media_queries();
                        foreach ($media_queries as $media_query) {
                            list($media_query_feature, $media_query_value) = $media_query;
                            // if any of the Style's media queries fail then do not apply the style
                            //TODO: When the media query logic is fully developed we should not apply the Style when any of the media queries fail or are bad, per https://www.w3.org/TR/css3-mediaqueries/#error-handling
                            if (in_array($media_query_feature, self::$VALID_MEDIA_TYPES)) {
                                if ((strlen($media_query_feature) === 0 && !in_array($media_query, $acceptedmedia)) || (in_array($media_query, $acceptedmedia) && $media_query_value == "not")) {
                                    continue (3);
                                }
                            } else {
                                switch ($media_query_feature) {
                                    case "height":
                                        if ($paper_height !== (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "min-height":
                                        if ($paper_height < (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "max-height":
                                        if ($paper_height > (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "width":
                                        if ($paper_width !== (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "min-width":
                                        //if (min($paper_width, $media_query_width) === $paper_width) {
                                        if ($paper_width < (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "max-width":
                                        //if (max($paper_width, $media_query_width) === $paper_width) {
                                        if ($paper_width > (float)$style->length_in_pt($media_query_value)) {
                                            continue (3);
                                        }
                                        break;
                                    case "orientation":
                                        if ($paper_orientation !== $media_query_value) {
                                            continue (3);
                                        }
                                        break;
                                    default:
                                        Helpers::record_warnings(E_USER_WARNING, "Unknown media query: $media_query_feature", __FILE__, __LINE__);
                                        break;
                                }
                            }
                        }

                        $style->merge($s);
                    }
                }
            }

            // Inherit parent's styles if required
            if ($p) {

                if ($DEBUGCSS) {
                    print "inherit:\n";
                    print "[\n";
                    $p->get_style()->debug_print();
                    print "]\n";
                }

                $style->inherit($p->get_style());
            }

            if ($DEBUGCSS) {
                print "DomElementStyle:\n";
                print "[\n";
                $style->debug_print();
                print "]\n";
                print "/$debug_nodename]\n</pre>";
            }

            /*DEBUGCSS print: see below different print debugging method
            Helpers::pre_r($frame->get_node()->nodeName . ":");
            echo "<pre>";
            echo $style;
            echo "</pre>";*/
            $frame->set_style($style);

            if (!$root_flg && $this->_page_styles["base"]) {
                $root_flg = true;

                // set the page width, height, and orientation based on the parsed page style
                if ($style->size !== "auto") {
                    list($paper_width, $paper_height) = $style->size;
                }
                $paper_width = $paper_width - (float)$style->length_in_pt($style->margin_left) - (float)$style->length_in_pt($style->margin_right);
                $paper_height = $paper_height - (float)$style->length_in_pt($style->margin_top) - (float)$style->length_in_pt($style->margin_bottom);
                $paper_orientation = ($paper_width > $paper_height ? "landscape" : "portrait");
            }
        }

        // We're done!  Clean out the registry of all styles since we
        // won't be needing this later.
        foreach (array_keys($this->_styles) as $key) {
            $this->_styles[$key] = null;
            unset($this->_styles[$key]);
        }

    }
229325
protected void generateBlockBundleCreation(SourceWriter sourceWriter, TreeLogger logger,
      GeneratorContext context) {

    // find all subclasses of NlsBundle
    TypeOracle typeOracle = context.getTypeOracle();
    JClassType bundleClass = typeOracle.findType(NlsBundle.class.getName());
    JClassType bundleWithLookupClass = typeOracle.findType(NlsBundleWithLookup.class.getName());
    JClassType[] types = typeOracle.getTypes();
    int bundleCount = 0;
    logger.log(Type.INFO, "Checking " + types.length + " types...");
    for (JClassType type : types) {
      if ((type.isAssignableTo(bundleClass))
          && (!type.equals(bundleClass) && (!type.equals(bundleWithLookupClass)))) {
        logger.log(Type.INFO, "Found NlsBundle interface: " + type);

        sourceWriter.print("if (");
        sourceWriter.print(type.getQualifiedSourceName());
        sourceWriter.println(".class == bundleInterface) {");
        sourceWriter.indent();

        sourceWriter.print("bundle = GWT.create(");
        sourceWriter.print(type.getQualifiedSourceName());
        sourceWriter.println(".class);");

        sourceWriter.println("register(bundleInterface, bundle);");

        sourceWriter.outdent();
        sourceWriter.print("} else ");

        bundleCount++;
      }
    }
    sourceWriter.println("{");
    sourceWriter.indent();

    sourceWriter.print("throw new ");
    sourceWriter.print(IllegalStateException.class.getSimpleName());
    sourceWriter.println("(\"Undefined NlsBundle \" + bundleInterface.getName());");

    sourceWriter.outdent();
    sourceWriter.println("}");

    logger.log(Type.INFO, "Found " + bundleCount + " NlsBundle interface(s).");
  }
83281
public function editBlockConfiguration(Tree $tree, int $block_id): void
    {
        $num             = $this->getBlockSetting($block_id, 'num', '10');
        $count_placement = $this->getBlockSetting($block_id, 'count_placement', 'before');

        $options = [
            /* I18N: An option in a list-box */
            'before' => I18N::translate('before'),
            /* I18N: An option in a list-box */
            'after'  => I18N::translate('after'),
        ];

        echo view('modules/top10_pageviews/config', [
            'count_placement' => $count_placement,
            'num'             => $num,
            'options'         => $options,
        ]);
    }
130639
public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
    {
        $calendar_service = new CalendarService();

        $default_events = implode(',', self::DEFAULT_EVENTS);

        $filter    = (bool) $this->getBlockSetting($block_id, 'filter', '1');
        $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
        $sortStyle = $this->getBlockSetting($block_id, 'sortStyle', 'alpha');
        $events    = $this->getBlockSetting($block_id, 'events', $default_events);

        extract($cfg, EXTR_OVERWRITE);

        $event_array = explode(',', $events);

        // If we are only showing living individuals, then we don't need to search for DEAT events.
        if ($filter) {
            $event_array  = array_diff($event_array, Gedcom::DEATH_EVENTS);
        }

        $events_filter = implode('|', $event_array);

        $startjd = Carbon::now()->julianDay();
        $endjd   = $startjd;

        $facts = $calendar_service->getEventsList($startjd, $endjd, $events_filter, $filter, $sortStyle, $tree);

        if (empty($facts)) {
            $content = view('modules/todays_events/empty');
        } elseif ($infoStyle === 'list') {
            $content = view('lists/anniversaries-list', [
                'facts' => $facts,
            ]);
        } else {
            $content = view('lists/anniversaries-table', [
                'facts' => $facts,
            ]);
        }

        if ($ctype !== '') {
            if ($ctype === 'gedcom' && Auth::isManager($tree)) {
                $config_url = route('tree-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } elseif ($ctype === 'user' && Auth::check()) {
                $config_url = route('user-page-block-edit', [
                    'block_id' => $block_id,
                    'ged'      => $tree->name(),
                ]);
            } else {
                $config_url = '';
            }

            return view('modules/block-template', [
                'block'      => Str::kebab($this->name()),
                'id'         => $block_id,
                'config_url' => $config_url,
                'title'      => $this->title(),
                'content'    => $content,
            ]);
        }

        return $content;
    }
99346
public static function formatText(string $text, Tree $tree): string
    {
        switch ($tree->getPreference('FORMAT_TEXT')) {
            case 'markdown':
                return '<div class="markdown" dir="auto">' . self::markdown($text, $tree) . '</div>';
            default:
                return '<div class="markdown" style="white-space: pre-wrap;" dir="auto">' . self::expandUrls($text, $tree) . '</div>';
        }
    }
1319020
private function renderRootNode(int $node_id): string
    {
        return sprintf('%s [ '.self::NODE_PROPS.' '.self::ROOT_NODE.' ];', $node_id, 'root');
    }