Get all the available blocks for a tree page.

@return Collection
@return ModuleBlockInterface[]
178179
private function availableTreeBlocks(): Collection
    {
        return $this->module_service->findByInterface(ModuleBlockInterface::class, false, true)
            ->filter(static function (ModuleBlockInterface $block): bool {
                return $block->isTreeBlock();
            })
            ->mapWithKeys(static function (ModuleInterface $block): array {
                return [$block->name() => $block];
            });
    }
1215770
public function getOnePageModules() : array
    {
        $modules = array();

        if (is_front_page() && is_plugin_active('modularity-onepage/modularity-onepage.php')) {
            $postStatus = array('publish');
            if (is_user_logged_in()) {
                $postStatus[] = 'private';
            }

            $sections = get_posts(array(
                'post_type' => 'onepage',
                'post_status' => $postStatus,
                'orderby' => 'menu_order',
                'order' => 'asc',
                'posts_per_page'   => -1
            ));

            foreach ($sections as $section) {
                $section_modules = \Modularity\Editor::getPostModules($section->ID);

                if (!isset($section_modules['onepage-sidebar'])) {
                    continue;
                }

                $section_modules = $section_modules['onepage-sidebar']['modules'];
                if (is_array($section_modules) && !empty($section_modules)) {
                    foreach ($section_modules as $module) {
                        if (!$module->hidden) {
                            $modules[] = $module;
                        }
                    }
                }
            }
        }

        return $modules;
    }
14038
public function getModules(){
		$modules=array();
		$db=BFactory::getDBO();
		if(empty($db)){
			return $modules; //False?
			}
		$qr='SELECT * from `soft_modules_rules` where pageid='.$this->id;
		$q=$db->Query($qr);
		if(empty($q)){
			return $modules; //False?
			}
		while($l=$db->fetch($q)){
			$id=(int)$l['id'];
			$modules[$id]=new BSoftModule();
			$modules[$id]->group=$this;
			$modules[$id]->load($l);
			}
		return $modules;
		}
1225620
public function modules()
    {
        $modules = [];

        foreach ($this->modulesToCheck as $module) {
            $modules[$module] = in_array('mod_' . $module, apache_get_modules());
        }

        return $modules;
    }
153149
public function getCollectionList()
    {
        $cArray = [];
        $bID = $this->getBlockID();
        if ($bID) {
            $db = Loader::db();
            $q = 'select DISTINCT Pages.cID from CollectionVersionBlocks inner join Pages on (CollectionVersionBlocks.cID = Pages.cID) inner join CollectionVersions on (CollectionVersions.cID = Pages.cID) where CollectionVersionBlocks.bID = ?';
            $r = $db->query($q, [$bID]);
            if ($r) {
                while ($row = $r->fetchRow()) {
                    $cArray[] = Page::getByID($row['cID'], 'RECENT');
                }
                $r->free();
            }
        }

        return $cArray;
    }
735962
public function getAllBlockNames()
    {
        $ret = [ ];
        try {
            $result = $this->getSoapClient()->GetBlockNames();
        } catch ( SoapException $ex ) {
            throw new StatusException('Error while getting the list of all blocks in the active template' , $ex);
        }
        if ( isset($result->GetBlockNamesResult->string) ) {
            if ( is_array($result->GetBlockNamesResult->string) ) {
                $ret = $result->GetBlockNamesResult->string;
            } else {
                $ret[] = $result->GetBlockNamesResult->string;
            }
        }

        return $ret;
    }
160958
protected function fetchBlockRecords()
    {
        $activeThemeId = oxNew(\OxidEsales\Eshop\Core\Theme::class)->getActiveThemeId();
        $config = Registry::getConfig();
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);

        $query = "select * from oxtplblocks where oxactive=1 and oxshopid=? and oxtheme in ('', ?)";

        return $database->select($query, [$config->getShopId(), $activeThemeId]);
    }
102829
public static function get_blockids_from_moduleid($moduleid) {
        global $DB;

        // Get the context of the module
        $contextid = context_module::instance($moduleid)->id;

        // Get all the block instances which parentcontextid is the module contextid
        $blockids = array();
        $instances = $DB->get_records('block_instances', array('parentcontextid' => $contextid), '', 'id');
        foreach ($instances as $instance) {
            $blockids[] = $instance->id;
        }
        return $blockids;
    }
254432
private function treeBlocks(int $tree_id, string $location): Collection
    {
        $rows = DB::table('block')
            ->where('gedcom_id', '=', $tree_id)
            ->where('location', '=', $location)
            ->orderBy('block_order')
            ->pluck('module_name', 'block_id');

        return $this->filterActiveBlocks($rows, $this->availableTreeBlocks());
    }
505865
protected function getClassDocBlockLines() {
    $docblock_lines = parent::getClassDocBlockLines();

    // Do not include the annotation if this plugin is a class override.
    if (!empty($this->component_data['replace_parent_plugin'])) {
      return $docblock_lines;
    }

    $docblock_lines[] = '';

    $docblock_lines = array_merge($docblock_lines, $this->classAnnotation());

    return $docblock_lines;
  }
1066076
public function getFunctions()
    {
        return array_merge(parent::getFunctions(), [
            new \Twig_SimpleFunction('getBlockElementsHtml', [$this, 'getBlockElementsHtml'], ['is_safe' => ['html']]),
            new \Twig_SimpleFunction('getElementHtml', [$this, 'getElementHtml'], ['is_safe' => ['html']]),
            new \Twig_SimpleFunction('getCollectionPages', [$this, 'getCollectionPages']),
            new \Twig_SimpleFunction('getGallery', [$this, 'getGallery']),
        ]);
    }
220681
public function treePageBlock(ServerRequestInterface $request, Tree $tree): ResponseInterface
    {
        $block_id = $request->get('block_id');

        $block_id = (int) DB::table('block')
            ->where('block_id', '=', $block_id)
            ->where('gedcom_id', '=', $tree->id())
            ->value('block_id');

        $module = $this->getBlockModule($tree, $block_id);

        $html = view('layouts/ajax', [
            'content' => $module->getBlock($tree, $block_id, 'gedcom'),
        ]);

        return response($html);
    }
1333266
protected function magic_get_blocks() {
        global $CFG;
        if (is_null($this->_blocks)) {
            if (!empty($CFG->blockmanagerclass)) {
                if (!empty($CFG->blockmanagerclassfile)) {
                    require_once($CFG->blockmanagerclassfile);
                }
                $classname = $CFG->blockmanagerclass;
            } else {
                $classname = 'block_manager';
            }
            $this->_blocks = new $classname($this);
        }
        return $this->_blocks;
    }
408371
public function getNumChildren()
    {
        $db = Loader::db();
        $q = 'select count(*) as total from CollectionVersionBlocks where bID = ? and isOriginal = 0';
        $total = $db->getOne($q, [$this->getBlockID()]);

        return $total;
    }
525970
public function getBlocksFromAppliedBlockSets($area = null, $includeDisabled = false)
	{
		$blocks = ArrayList::create();
		$sets = $this->getAppliedSets();

		if (!$sets->count()) {
			return $blocks;
		}

		foreach ($sets as $set) {
			$setBlocks = $set->Blocks()->sort('Sort DESC');

			if (!$includeDisabled) {
				$setBlocks = $setBlocks->exclude('ID', $this->owner->DisabledBlocks()->column('ID'));
			}

			if ($area) {
				$setBlocks = $setBlocks->filter('BlockArea', $area);
			}

			$blocks->merge($setBlocks);
		}

		$blocks->removeDuplicates();

		return $blocks;
	}
1026464
public function getBlocks()
    {
        $ungroupedKey = 'Ungrouped';
        $blockGroups = array();
        foreach ($this->blockManagersItems as $blockManagerItem) {

            if ($blockManagerItem->getBlockManager()->getIsInternalBlock()) {
                continue;
            }

            $groups = array($ungroupedKey);
            $group = $blockManagerItem->getGroup();
            if ($group != "") {
                $groups = explode(",", $group);
                if ($group != "redkitecms_internals" && count($groups) == 1) {
                    $groups = array($ungroupedKey);
                }
            }

            $blockGroup = array($blockManagerItem->getType() => array('description' => $blockManagerItem->getDescription(), 'filter' => $blockManagerItem->getFilter()));
            foreach (array_reverse($groups) as $key) {
               $blockGroup = array(trim($key) => $blockGroup);
            }
            $blockGroups = array_merge_recursive($blockGroups, $blockGroup);
        }

        // First displayed group
        $redKiteBlocks = array("Base" => $this->extractGroup('redkitecms_internals', $blockGroups));
        // Last displayed group
        $notGrouped = $this->extractGroup($ungroupedKey, $blockGroups);
        // Sorts
        $this->recurKsort($redKiteBlocks);
        if (count($notGrouped) > 0) {
            $this->recurKsort($notGrouped);
        }

        // Exstracts and sorts all other groups
        $blocks = array();
        foreach ($blockGroups as $blockGroup) {
            $blocks = array_merge($blocks, $blockGroup);
        }
        $this->recurKsort($blocks);

        // Merges blocks
        $blocks = array_merge($redKiteBlocks, $blocks);
        if ( ! empty($notGrouped)) {
            $blocks = array_merge($blocks, array($ungroupedKey => $notGrouped));
        }

        return $blocks;
    }
22178
public function toArray()
	{
		return array_map(static function(PhpCommentBlock $block) {
			if($block->isTextNode())
			{
				return [
					"type"  => "text",
					"lines" => $block->getLines()
				];
			}
			else
			{
				return [
					"type"  => "block",
					"name"  => $block->getName(),
					"lines" => $block->getLines()
				];
			}
		}, $this->items);
	}