Render a given model.

@param ModelInterface $model    The model to render.
@param string         $toggleID The id of the toggler.

@return string
499025
protected function parseModel($model, $toggleID)
    {
        $model->setMeta($model::LABEL_VALUE, $this->formatModel($model));

        if ($model->getMeta($model::SHOW_CHILDREN)) {
            $toggleTitle = $this->getEnvironment()->getTranslator()->translate('collapseNode', 'MSC');
        } else {
            $toggleTitle = $this->getEnvironment()->getTranslator()->translate('expandNode', 'MSC');
        }

        $toggleScript = \sprintf(
            'Backend.getScrollOffset(); return BackendGeneral.loadSubTree(this, ' .
            '{\'toggler\':\'%s\', \'id\':\'%s\', \'providerName\':\'%s\', \'level\':\'%s\', \'url\':\'%s\'});',
            $toggleID,
            $model->getId(),
            $model->getProviderName(),
            $model->getMeta('dc_gen_tv_level'),
            $this->generateToggleUrl($model)
        );

        $template = new ContaoBackendViewTemplate('widget_treepicker_entry');
        $template
            ->setTranslator($this->getEnvironment()->getTranslator())
            ->set('id', $this->strId)
            ->set('name', $this->strName)
            ->set('theme', Backend::getTheme())
            ->set('fieldType', $this->fieldType)
            ->set('environment', $this->getEnvironment())
            ->set('objModel', $model)
            ->set('strToggleID', $toggleID)
            ->set('toggleUrl', $this->generateToggleUrl($model))
            ->set('toggleTitle', $toggleTitle)
            ->set('toggleScript', $toggleScript)
            ->set('active', static::optionChecked($model->getProperty($this->idProperty), $this->value))
            ->set('idProperty', $this->idProperty);

        $level = $model->getMeta(DCGE::TREE_VIEW_LEVEL);
        if (($this->minLevel > 0) && ($level < ($this->minLevel - 1))) {
            $template->set('fieldType', 'none');
        }
        if (($this->maxLevel > 0) && ($level > ($this->maxLevel - 1))) {
            $template->set('fieldType', 'none');
        }

        return $template->parse();
    }
1274145
public function render(ElementInterface $element)
    {
        /* @var $element DisableElementsCapableFormSettings
         * @var $renderer   \Zend\View\Renderer\PhpRenderer
         * @var $headscript \Zend\View\Helper\HeadScript
         * @var $basepath   \Zend\View\Helper\BasePath */
        $renderer   = $this->getView();
        $headscript = $renderer->plugin('headscript');
        $basepath   = $renderer->plugin('basepath');

        $headscript->appendFile($basepath('modules/Settings/js/forms.decfs.js'));

        return '<ul class="disable-elements-list" id="' . $element->getAttribute('id') . '-list"' . '>'
               . $this->renderCheckboxes($element->getCheckboxes())
               . '</ul>';
    }
1041316
public function render(Model $model, $source)
    {
        if (null === $this->resolveModelSource($model, $source)) {
            return '';
        }

        return parent::render($model, $source);
    }
404101
public function toggleButtonRow($model, $attribute, $htmlOptions = array())
	{
		return $this->inputRow(CiiInput::TYPE_TOGGLEBUTTON, $model, $attribute, null, $htmlOptions);
	}
1210822
private function toggle($id)
    {
        $Eresus = Eresus_CMS::getLegacyKernel();

        $item = $Eresus->db->selectItem($this->table['name'], "`id`='" . $id . "'");
        $item['active'] = !$item['active'];

        $item = $Eresus->db->escape($item);
        $Eresus->db->updateItem($this->table['name'], $item, "`id`='" . $id . "'");

        HTTP::redirect(Eresus_Kernel::app()->getPage()->url());
    }
759486
public function actionView(string $id)
    {
        $model = $this->findModel($id);

        return $this->render('view', ['model' => $model]);
    }
153390
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = [])
	{
		$this->context->bind($model);
		$this->context->set('@view', $this);
		
		foreach($params as $k => $v)
		{
			$this->context->set($k, $v);
		}
		
		try
		{
			if($this->getParent() === NULL)
			{
				$this->renderMain($out);
			}
			else
			{
				$this->parent->renderMain($out);
			}

			return $out;
		}
		finally
		{
			$this->parent = false;
			$this->context->unbind();
		}
	}
551460
public function render(ViewModelInterface $model)
    {
        foreach ($model as $child) {
            $groupId = $child->getGroupId();
            if (empty($groupId)) {
                continue;
            }
            $result    = $this->render($child);
            $oldResult = $model->getVariable($groupId, '');
            $model->setVariable($groupId, $oldResult . $result);
        }

        $events = $this->getEvents();
        $event  = new ViewEvent($model);
        $events->trigger($event);

        return $event->getResult();
    }
69145
private static function getRenderer($id)
    {
        if (!isset(self::$renderers[$id])) {
            throw new \InvalidArgumentException("no such renderer: ".$id);
        }
        return self::$renderers[$id];
    }
361407
public function toggleAction($id)
    {
        /** @var Menus_Entity_Table_Menu $table */
        $table = ORM::getTable($this->plugin, 'Menu');
        /** @var Menus_Entity_Menu $menu */
        $menu = $table->find($id);

        if (!is_null($menu))
        {
            $menu->active = !$menu->active;
            $table->update($menu);
        }

        HTTP::redirect(str_replace('&amp;', '&', $this->ui->url()));
    }
1018992
public function getName(Model $model, $id = null) {
		if (empty($id) || empty($model->displayField)) {
			return false;
		}
		if (is_array($id)) {
			if (!isset($id[$model->alias][$model->displayField])) {
				return false;
			}

			$result = $id[$model->alias][$model->displayField];
		} else {
			$model->id = $id;
			$result = $model->field($model->displayField);
		}

		return $result;
	}
987453
public function renderBlock(BlockInterface $block, $arguments = array())
    {
        /** @var BlockManager $manager */
        $manager = $this->container->get('opifer.content.block_manager');

        $service = $manager->getService($block);

        if ($this->blockEnvironment->getBlockMode($block) == 'manage') {
            $content =  $service->setEnvironment($this->blockEnvironment)->manage($block)->getContent();
//            $block->isRendered = true;
//
//            // TODO check for unrendered blocks
//            if ($block instanceof BlockContainerInterface) {
//                foreach ($block->getChildren() as $child) {
//                    if (!property_exists($child, 'isRendered') || $child->isRendered) {
//                        $content .= $manager->getService($child)->manage($child)->getContent();
//                    }
//                }
//            }

            return $content;
        }

        return $service->execute($block)->getContent();
    }
529098
public function toggleModel($providerName, $modelId)
    {
        if (!isset($this->states[$providerName])) {
            $this->states[$providerName] = [];
        }

        return $this->setModelState($providerName, $modelId, !$this->isModelOpen($providerName, $modelId, true));
    }
557347
protected function renderButton($name, $model, $key, $index)
    {
        if (!isset($this->buttons[$name])) {
            return '';
        }
        $button = $this->buttons[$name];

        if ($button instanceof \Closure) {
            $url = $this->createUrl($name, $model, $key, $index);
            return call_user_func($button, $url, $model, $key);
        }
        if (!is_array($button)) {
            throw new InvalidConfigException("Button should be either a Closure or array configuration.");
        }

        // Visibility :
        if (isset($button['visible'])) {
            if ($button['visible'] instanceof \Closure) {
                if (!call_user_func($button['visible'], $model, $key, $index)) {
                    return '';
                }
            } elseif (!$button['visible']) {
                return '';
            }
        }

        // URL :
        if (isset($button['url'])) {
            $url = call_user_func($button['url'], $name, $model, $key, $index);
        } else {
            $url = $this->createUrl($name, $model, $key, $index);
        }

        // label :
        if (isset($button['label'])) {
            $label = $button['label'];

            if (isset($button['encode'])) {
                $encodeLabel = $button['encode'];
                unset($button['encode']);
            } else {
                $encodeLabel = true;
            }
            if ($encodeLabel) {
                $label = Html::encode($label);
            }
        } else {
            $label = '';
        }

        // icon :
        if (isset($button['icon'])) {
            $icon = $button['icon'];
            $label = Html::icon($icon) . (empty($label) ? '' : ' ' . $label);
        }

        $options = array_merge(ArrayHelper::getValue($button, 'options', []), $this->buttonOptions);

        return Html::a($label, $url, $options);
    }
582124
public function toggleVisibility($intId, $blnVisible, DataContainer $dc=null)
	{
		$db = Database::getInstance();
		
		// Set the ID and action
		\Input::setGet('id', $intId);
		\Input::setGet('act', 'toggle');
		
		if ($dc)
		{
			$dc->id = $intId; // see #8043
		}
		
		if (!$this->User->isAdmin)
		{
			return;
		}		
				
		// Check the field access
		if (!$this->User->hasAccess($this->table . '::invisible', 'alexf'))
		{
			$this->log('Not enough permissions to publish/unpublish content element ID "'.$intId.'"', __METHOD__, TL_ERROR);
			$this->redirect('contao/main.php?act=error');
		}
		
		// The onload_callbacks vary depending on the dynamic parent table (see #4894)
		if (is_array($GLOBALS['TL_DCA'][$this->table]['config']['onload_callback']))
		{
			foreach ($GLOBALS['TL_DCA'][$this->table]['config']['onload_callback'] as $callback)
			{
				if (is_array($callback))
				{
					$this->import($callback[0]);
					$this->{$callback[0]}->{$callback[1]}(($dc ?: $this));
				}
				elseif (is_callable($callback))
				{
					$callback(($dc ?: $this));
				}
			}
		}
		
		// Check permissions to publish
		if (!$this->User->hasAccess($this->table . '::invisible', 'alexf'))
		{
			$this->log('Not enough permissions to show/hide content element ID "'.$intId.'"', __METHOD__, TL_ERROR);
			$this->redirect('contao/main.php?act=error');
		}
		
		$objVersions = new Versions($this->table, $intId);
		$objVersions->initialize();
		
		// Trigger the save_callback
		if (is_array($GLOBALS['TL_DCA'][$this->table]['fields']['invisible']['save_callback']))
		{
			foreach ($GLOBALS['TL_DCA'][$this->table]['fields']['invisible']['save_callback'] as $callback)
			{
				if (is_array($callback))
				{
					$this->import($callback[0]);
					$blnVisible = $this->{$callback[0]}->{$callback[1]}($blnVisible, ($dc ?: $this));
				}
				elseif (is_callable($callback))
				{
					$blnVisible = $callback($blnVisible, ($dc ?: $this));
				}
			}
		}
		
		// Update the database
		$db->prepare("UPDATE " . $this->table . " SET tstamp=". time() .", invisible='" . ($blnVisible ? '' : 1) . "' WHERE id=?")
		   ->execute($intId);
					   
		$objVersions->create();
		$this->log('A new version of record "' . $this->table . '.id='.$intId.'" has been created'.$this->getParentEntries('tl_pattern', $intId), __METHOD__, TL_GENERAL);
	}
179756
public function render(Model $model, $source)
    {
        $value = $this->resolveModelSource($model, $source);

        if (null === $value) {
            return null;
        }

        if ($value) {
            return cms_trans('common.boolean.true');
        }

        return cms_trans('common.boolean.false');
    }
110133
public function show($id)
    {
        $component = $this->component($id)->templateLayout();
        $html      = $component->__toString();
        if (!strlen($html)) {
            return $component->render();
        }
        return $html;
    }