_block :: insert content block
Parameter "name" is the name of block;

@param array $ret ©NeosTag data array
@return string|html
437501
private function _block($ret)
    {
        if(!isset($ret['name'])) return '';
        $ret['-content-'] .= $this->getBlock(trim($ret['name']));
        if($ret['-content-'] == false) return '';

        unset($ret['name']);
        return $this->setAttributes($ret);
    }
609468
public function callBlock(string $block = '', ...$params): ?string
    {
        /** @var ModuleBlockInterface|null $module */
        $module = $this->module_service
            ->findByComponent(ModuleBlockInterface::class, $this->tree, Auth::user())
            ->first(static function (ModuleInterface $module) use ($block): bool {
                return $module->name() === $block && $module->name() !== 'html';
            });

        if ($module === null) {
            return '';
        }

        // Build the config array
        $cfg = [];
        foreach ($params as $config) {
            $bits = explode('=', $config);

            if (count($bits) < 2) {
                continue;
            }

            $v       = array_shift($bits);
            $cfg[$v] = implode('=', $bits);
        }

        return $module->getBlock($this->tree, 0, '', $cfg);
    }
568901
public function getBlock($block_id, $template = true, $cfg = array()) {
        Globals::getController()->addInlineJavascript('
			$(document).ready(function(){
				$.ajax({
					url: "module.php",
					data : {
						mod: "'.$this->getName().'",
						mod_action: "Task@trigger",
					},
				});
			});
		');
        return '';
    }
782337
protected function _parseBlock() {
        $this->_content = preg_replace_callback('`' . $this->_openTag . $this->_name . preg_quote($this->markup['block'][0]) . $this->_spaceR . preg_quote($this->markup['block'][1]) . $this->_space . '=' . $this->_space . '"' . $this->_space . '(\w+)\(\)' . $this->_space . '"' . $this->_space . $this->_closeTag . '(.*)' . $this->_openTag . '/' . $this->_name . $this->markup['block'][0] . $this->_space . $this->_closeTag . '`isU', ['Gcs\Framework\Core\Template\Parser', '_parseBlockCallback'], $this->_content);
    }
365977
public function addStack($blockName, array $args = array())
    {
        if (isset($this->plugins[$blockName])) {
            $class = $this->plugins[$blockName]['class'];
        } else {
            $class = current(array_filter([
                'Plugin' . self::toCamelCase($blockName),
                self::NAMESPACE_PLUGINS_BLOCKS . 'Plugin' . self::toCamelCase($blockName)
            ], 'class_exists'));
        }

        if ($this->curBlock !== null) {
            $this->curBlock->buffer(ob_get_contents());
            ob_clean();
        } else {
            $this->buffer .= ob_get_contents();
            ob_clean();
        }

        $block = new $class($this);

        call_user_func_array(array($block, 'init'), $args);

        $this->stack[] = $this->curBlock = $block;

        return $block;
    }
632440
public function show(ReadBlockInterface $block)
    {
        $contents = $this->getContents($block->getAttribute('contentSearch'));

        if (!is_null($contents)) {

            $parameters = array(
                'contents' => $contents,
                'class' => $block->getStyle(),
                'id' => $block->getId(),
                'characterNumber' => $block->getAttribute('characterNumber')
            );

            if ('' != $block->getAttribute('contentNodeId')) {
                $language = $this->currentSiteManager->getSiteLanguage();
                $siteId = $this->currentSiteManager->getSiteId();
                $node = $this->nodeRepository->findOnePublished($block->getAttribute('contentNodeId'), $language, $siteId);
                $parameters['contentNodeId'] = $node->getId();

                if (!$this->isGrantedNode($node)) {
                    unset($parameters['contentNodeId']);
                }
            }

            return $this->render('OpenOrchestraDisplayBundle:Block/ContentList:show.html.twig', $parameters);
        }

        throw new ContentNotFoundException();
    }
21361
public function addBlock($name, array $data)
    {
        if(!isset($this->__blocks[$name])) {
            $this->__blocks[$name] = array();
        }

        $this->__blocks[$name][] = $data;

        return $this;
    }
139717
protected function replaceParentBlock($savedContent)
    {
       $pattern = sprintf(self::TMPL_RENDER_PARENT, "([^']+)", "([^|]+)");
       $result = preg_match("/{$pattern}/", $savedContent, $matches);
       if (!$result) {
           return $savedContent;
       } else { // processing parentBlock()
           $fullBlockName = $matches[1];
           $viewFileName = $matches[2];
           $replacement = $this->findParentBlock($fullBlockName, $viewFileName);
           $out = preg_replace("/{$pattern}/", $replacement, $savedContent);
           return $out;
       }
    }
951676
public function renderBlock(string $blockName): string
    {
        if (!$this->template->hasBlock($blockName, $this->context, $this->blocks)) {
            return '';
        }

        $level = ob_get_level();
        ob_start();

        try {
            $this->template->displayBlock($blockName, $this->context, $this->blocks);
        } catch (Throwable $t) {
            while (ob_get_level() > $level) {
                ob_end_clean();
            }

            throw $t;
        }

        return (string) ob_get_clean();
    }
170651
public static function autoEncode( $ret, $type = null )
    {
        if ( $type === null )
            $type = self::getHttpAccept( );

        if ( $type === 'xml' )
            return self::xmlEncode( $ret );
        else if ( $type === 'json' )
            return json_encode( $ret );
        else
            return self::textEncode( $ret );
    }
755856
private function handleCtrlResult($ret)
    {
        if ($ret === null) {
            return;
        }
        register_shutdown_function("closeResources");
        if (isset($_GET['format']) && $_GET['format'] == 'xml') {
            header('Content-type: application/xml; charset=utf-8');
            $ret = (object)$ret;
            echo $this->objectToXml($ret);
            die;
        }
        header('Content-type: application/json; charset=utf-8');
        echo json_encode($ret);
        die;
    }
1226672
public function builder($ret, $data, $msg = '', $format = 'json')
    {
        @header('Content-type: application/json; charset=utf-8');
        $this->ret  = strval($ret);
        $this->time = time();
        $this->msg  = $msg;
        $this->data = $data;
        $this->format = $format;
    }
1022731
public static function renderBlocks($name, $args = array())
    {
        global $PPHP, $_SESSION;

        array_merge_assoc(
            self::$_stash,
            $args,
            array(
                'config' => $PPHP['config'],
                'session' => $_SESSION,
                'req' => grab('request')
            )
        );
        try {
            $template = self::$_twig->loadTemplate($name);
            $blockNames = $template->getBlockNames(self::$_stash);
            $results = array();
            foreach ($blockNames as $blockName) {
                $results[$blockName] = $template->renderBlock($blockName, self::$_stash);
            };
        } catch (\Exception $e) {
            echo $e->getMessage();
        };
        return $results;
    }
482865
protected function process_block_rule($name, $block) {
        $this->rulestack[] = array('callback' => method_exists($this, $name."_block_rule") ? $name."_block_rule" : null, 'rule' => $block);

        $this->string = preg_replace_callback($block['expression'], array($this, 'block_callback'), $this->string);

        array_pop($this->rulestack);
    }
206409
public function submit($postContent)
    {
        $postContent['select'] = !empty($postContent['select']) ? $postContent['select'] : [];

        if ($postContent['custom']) {
            $newOptions = explode(',', $postContent['custom']);
            $optionsArr = [];
            $options = BlockSelectOption::where('block_id', '=', $this->_block->id)->get();
            if (!$options->isEmpty()) {
                foreach ($options as $option) {
                    $optionsArr[$option->value] = $option->option;
                }
            }
            foreach ($newOptions as $newOption) {
                $newOption = trim($newOption);
                if ($newOption && empty($optionsArr[$newOption])) {
                    $optionsArr[$newOption] = $newOption;
                }
            }
            BlockSelectOption::import($this->_block->id, $optionsArr);
            $postContent['select'] = array_merge($postContent['select'], $newOptions);
        }

        return $this->save(!empty($postContent['select']) ? serialize($postContent['select']) : '');
    }
843822
def insert_block(position, anchor_block, new_block)
      case position
      when :before
        anchor_block.xml.previous_sibling = new_block.xml
      when :after
        anchor_block.xml.next_sibling = new_block.xml
      else
        raise "position argument must be one of :before, :after"
      end
    end
729898
public function addTab(string $name, BlockInterface $block){
        $this->tabs[]   = [
            "name"  => $name,
            "block" => $block,
        ];

        return $this;
    }