1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82:
<?php
namespace Nethgui\Module\Help;
class Widget extends \Nethgui\Widget\AbstractWidget
{
protected function renderContent()
{
$whatToDo = $this->getAttribute('do');
$view = NULL;
if ($whatToDo === 'inset') {
$view = $this->view->offsetGet($this->getAttribute('name'));
} elseif ($whatToDo === 'literal' && $this->getAttribute('isPluginPlaceholder') === TRUE) {
return $this->getAttribute('data');
} elseif ($whatToDo === 'literal' && $this->getAttribute('isPlugin') === TRUE) {
$view = $this->getAttribute('data');
}
if ($view instanceof \Nethgui\View\ViewInterface) {
$renderer = $this->view->spawnRenderer($view);
$renderer->nestingLevel = $this->view->nestingLevel + 1;
return $renderer->render();
}
return parent::renderContent();
}
public function insertPlugins($name = 'Plugin')
{
$module = $this->view->getModule();
if ($module instanceof \Nethgui\Controller\Table\PluggableAction) {
$module = $module->getParent();
}
$pattern = str_replace('\\', '_', get_class($module)) . '_' . $name . '_*.rst';
$pluginPlaceholder = $this->view->literal('{{{INCLUDE ' . $pattern . '}}}');
$pluginPlaceholder->setAttribute('isPluginPlaceholder', TRUE);
$this->insert($pluginPlaceholder);
$pluginsPanel = $this->view->panel();
foreach ($this->view[$name] as $pluginView) {
if ($pluginView instanceof \Nethgui\View\ViewInterface) {
$pluginsPanel->insert(
$this->view->literal($pluginView)
->setAttribute('isPlugin', TRUE)
);
}
}
$this->insert($pluginsPanel);
return $this;
}
}