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: 83: 84:
<?php
namespace Nethgui\Module\Help;
class Show extends Common
{
private $helpContent = '';
public function prepareView(\Nethgui\View\ViewInterface $view)
{
parent::prepareView($view);
if (is_null($this->getTargetModule())) {
$view->setTemplate(array($this, 'renderIndex'));
} else {
$this->helpContent = $this->readHelpDocument(
$this->getHelpDocumentPath($this->getTargetModule()
));
$view->setTemplate(array($this, 'renderDocument'));
}
}
public function renderIndex(\Nethgui\Renderer\Xhtml $renderer)
{
$moduleList = $renderer->elementList();
$templateList = $renderer->elementList();
$translator = $renderer->getTranslator();
$renderer->rejectFlag($renderer::INSET_FORM);
foreach ($this->getModuleSet() as $module) {
if ($module === $this->getParent()) {
continue;
}
$template = '<a href="%URL">%LABEL</a>';
$args1 = array('%URL' => $renderer->getModuleUrl($module->getIdentifier()) . '.rst', '%LABEL' => $translator->translate($module, $module->getAttributesProvider()->getTitle()));
$args2 = array('%URL' => $renderer->getModuleUrl('../Template/' . $module->getIdentifier()) . '.rst', '%LABEL' => $translator->translate($module, $module->getAttributesProvider()->getTitle()));
$moduleList->insert($renderer->literal(strtr($template, $args1)));
$templateList->insert($renderer->literal(strtr($template, $args2)));
}
return $renderer->columns()
->insert($renderer->fieldset()->setAttribute('template', $renderer->translate('Documents'))->insert($moduleList))
->insert($renderer->fieldset()->setAttribute('template', $renderer->translate('Templates'))->insert($templateList))
;
}
public function renderDocument(\Nethgui\Renderer\Xhtml $renderer)
{
$renderer->rejectFlag($renderer::INSET_FORM);
return $renderer->panel()->setAttribute('class', 'HelpDocument')->insert($renderer->literal($this->helpContent));
}
}