Prints a nice side block with an optional header.

@param block_contents $bc HTML for the content
@param string $region the region the block is appearing in.
@return string the HTML to be output.
896
public function block(block_contents $bc, $region) {
        $bc = clone($bc); // Avoid messing up the object passed in.
        if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) {
            $bc->collapsible = block_contents::NOT_HIDEABLE;
        }

        $id = !empty($bc->attributes['id']) ? $bc->attributes['id'] : uniqid('block-');
        $context = new stdClass();
        $context->skipid = $bc->skipid;
        $context->blockinstanceid = $bc->blockinstanceid;
        $context->dockable = $bc->dockable;
        $context->id = $id;
        $context->hidden = $bc->collapsible == block_contents::HIDDEN;
        $context->skiptitle = strip_tags($bc->title);
        $context->showskiplink = !empty($context->skiptitle);
        $context->arialabel = $bc->arialabel;
        $context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : 'complementary';
        $context->type = $bc->attributes['data-block'];
        $context->title = $bc->title;
        $context->content = $bc->content;
        $context->annotation = $bc->annotation;
        $context->footer = $bc->footer;
        $context->hascontrols = !empty($bc->controls);
        if ($context->hascontrols) {
            $context->controls = $this->block_controls($bc->controls, $id);
        }

        return $this->render_from_template('core/block', $context);
    }
1218323
public function show(BlockRequest $request, Block $block)
    {

        if ($block->exists) {
            $view = 'block::admin.block.show';
        } else {
            $view = 'block::admin.block.new';
        }

        return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::block.name'))
            ->data(compact('block'))
            ->view($view)
            ->output();
    }
442006
public function contentToRegion($region, $content)
    {
        $regions = $this->contentRegion->findBy(array('content' => $content));

        if (count($regions) === 1 and $regions[0]->getRegion()->getName() === $region->getName()) {
            $this->deleteRegions($content, $regions);
        } else {
            $this->deleteRegions($content, $regions);

            $first = $this->contentRegion->findOneBy(array('back' => null, 'region' => $region));
            $contentRegion = new Content2Region($first);
            $contentRegion->setRegion($region);
            $contentRegion->setContent($content);
            $this->manager->persist($contentRegion);
            $this->manager->flush();
        }
    }
1334678
public function render(AbstractBlock $block, CliRenderer $renderer)
    {
        if (!($block instanceof FencedCode)) {
            throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
        }

        $infoWords = $block->getInfoWords();
        $codeType = null;
        if (count($infoWords) !== 0 && strlen($infoWords[0]) !== 0) {
            $codeType = $infoWords[0];
        }

        if (null === $codeType || !isset($this->highlighters[$codeType])) {
            return $this->indent($renderer->style($block->getStringContent(), 'yellow'));
        }

        return $this->indent(
            sprintf("%s\n", $this->highlighters[$codeType]->highlight($block->getStringContent()))
        );
    }
1009849
protected function block(OutputBlock $block)
    {
        if (empty($block->lines) && empty($block->children)) {
            return;
        }

        $this->currentBlock = $block;

        $pre = $this->indentStr();

        if (! empty($block->selectors)) {
            $this->blockSelectors($block);

            $this->indentLevel++;
        }

        if (! empty($block->lines)) {
            $this->blockLines($block);
        }

        if (! empty($block->children)) {
            $this->blockChildren($block);
        }

        if (! empty($block->selectors)) {
            $this->indentLevel--;

            if (empty($block->children)) {
                $this->write($this->break);
            }

            $this->write($pre . $this->close . $this->break);
        }
    }
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();
    }
631604
public RegionPageSectionBuilder region(final PageSectionContent.Region region) {
		switch (region) {
		case LEFT: // Use left region
			this.curRegionBox = this.leftRegionBox;
			break;
		case CENTER: // Use center region
			this.curRegionBox = this.centerRegionBox;
			break;
		case RIGHT: // Use right region
			this.curRegionBox = this.rightRegionBox;
			break;
		default: // Invalid footerRegionValue, use center region as default
			throw new IllegalStateException();
		}
		return this;
	}
512652
private function renderPlainText(&$content, $text, $encoding, $boundary)
    {
        $content .= "\r\n";
        $content .= "--$boundary\r\n";
        $content .= "Content-Type: text/plain;\r\n\tcharset=\"$encoding\"\r\n";
        $content .= "Content-Transfer-Encoding: quoted-printable\r\n";
        $content .= "\r\n";
        $content .= "$text\r\n";
    }
138167
public function setRegion($region)
    {
        $this->region = strtolower($region);

        $this->updateApiUrl($region);
        $this->updateApiAccessTokenUrl($region);

        return $this;
    }
314174
protected function frontpage_part($skipdivid, $contentsdivid, $header, $contents) {
        if (strval($contents) === '') {
            return '';
        }
        $output = html_writer::link('#' . $skipdivid,
            get_string('skipa', 'access', core_text::strtolower(strip_tags($header))),
            array('class' => 'skip-block skip'));

        // Wrap frontpage part in div container.
        $output .= html_writer::start_tag('div', array('id' => $contentsdivid));
        $output .= $this->heading($header);

        $output .= $contents;

        // End frontpage part div container.
        $output .= html_writer::end_tag('div');

        $output .= html_writer::tag('span', '', array('class' => 'skip-block-to', 'id' => $skipdivid));
        return $output;
    }
1179758
protected function renderRawHtml($block)
	{
        $output = $block['content'];
        if (is_callable($this->rawHtmlFilter, true)) {
            $output = call_user_func($this->rawHtmlFilter, $output);
        }
		return $output . "\n";
	}
435748
public function get_content_for_region($region, $output) {
        $this->check_is_loaded();
        $this->ensure_content_created($region, $output);
        return $this->visibleblockcontent[$region];
    }
1232828
final public void printContentHorizontalDivider(ChainWriter out, WebSiteRequest req, HttpServletResponse resp, int colspan, boolean endsInternal) throws IOException, SQLException {
		printContentHorizontalDivider(out, req, resp, new int[] {colspan}, endsInternal);
	}
568969
public function render(AbstractBlock $block, CliRenderer $renderer)
    {
        if (!($block instanceof Document)) {
            throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
        }

        $wholeDoc = $renderer->renderBlocks($block->children());
        return $wholeDoc === '' ? '' : $wholeDoc . "\n";
    }
1161019
private function getRegionTitle($region)
    {
        $region = str_replace('_', ' ', $region);

        $region = explode('/', $region);
        $title = array_shift($region);
        foreach ($region as $part) {
            $title .= ' (' . $part . ')';
        }

        return $title;
    }
1248432
public function getRegion($region)
    {
        $session = $this->getSession();
        $regionObj = $session->getPage()->find('region', $region);
        if (!$regionObj) {
            throw new \Exception(sprintf('No region "%s" found on the page %s.', $region, $session->getCurrentUrl()));
        }

        return $regionObj;
    }
1193749
public void writeBlock(byte[] block) throws IOException {

        if (block.length != 512) {
            throw new IllegalArgumentException(
                RB.singleton.getString(RB.BAD_BLOCK_WRITE_LEN, block.length));
        }

        write(block, block.length);
    }