1*f09444ffSAndreas Gohr<?php 2*f09444ffSAndreas Gohr 3*f09444ffSAndreas Gohruse dokuwiki\Form\Form; 4*f09444ffSAndreas Gohr 5*f09444ffSAndreas Gohr/** 6*f09444ffSAndreas Gohr * DokuWiki Plugin acknowledge (Admin Component) 7*f09444ffSAndreas Gohr * 8*f09444ffSAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9*f09444ffSAndreas Gohr * @author Andreas Gohr, Anna Dabrowska <dokuwiki@cosmocode.de> 10*f09444ffSAndreas Gohr */ 11*f09444ffSAndreas Gohrclass admin_plugin_acknowledge_assign extends \dokuwiki\Extension\AdminPlugin 12*f09444ffSAndreas Gohr{ 13*f09444ffSAndreas Gohr /** @inheritDoc */ 14*f09444ffSAndreas Gohr public function getMenuText($language) 15*f09444ffSAndreas Gohr { 16*f09444ffSAndreas Gohr return $this->getLang('menu_assign'); 17*f09444ffSAndreas Gohr } 18*f09444ffSAndreas Gohr 19*f09444ffSAndreas Gohr 20*f09444ffSAndreas Gohr /** @inheritDoc */ 21*f09444ffSAndreas Gohr public function handle() 22*f09444ffSAndreas Gohr { 23*f09444ffSAndreas Gohr global $INPUT; 24*f09444ffSAndreas Gohr 25*f09444ffSAndreas Gohr /** @var helper_plugin_acknowledge $helper */ 26*f09444ffSAndreas Gohr $helper = plugin_load('helper', 'acknowledge'); 27*f09444ffSAndreas Gohr 28*f09444ffSAndreas Gohr $pattern = $INPUT->arr('pattern'); 29*f09444ffSAndreas Gohr $assignees = $INPUT->arr('assignees'); 30*f09444ffSAndreas Gohr $patterns = array_combine($pattern, $assignees); 31*f09444ffSAndreas Gohr 32*f09444ffSAndreas Gohr if ($patterns && checkSecurityToken()) { 33*f09444ffSAndreas Gohr $helper->saveAssignmentPatterns($patterns); 34*f09444ffSAndreas Gohr } 35*f09444ffSAndreas Gohr 36*f09444ffSAndreas Gohr } 37*f09444ffSAndreas Gohr 38*f09444ffSAndreas Gohr /** @inheritDoc */ 39*f09444ffSAndreas Gohr public function html() 40*f09444ffSAndreas Gohr { 41*f09444ffSAndreas Gohr echo $this->locale_xhtml('assign'); 42*f09444ffSAndreas Gohr 43*f09444ffSAndreas Gohr /** @var helper_plugin_acknowledge $helper */ 44*f09444ffSAndreas Gohr $helper = plugin_load('helper', 'acknowledge'); 45*f09444ffSAndreas Gohr 46*f09444ffSAndreas Gohr $assignments = $helper->getAssignmentPatterns(); 47*f09444ffSAndreas Gohr 48*f09444ffSAndreas Gohr $form = new Form(['method' => 'post']); 49*f09444ffSAndreas Gohr $form->setHiddenField('do', 'admin'); 50*f09444ffSAndreas Gohr $form->setHiddenField('page', 'acknowledge_assign'); 51*f09444ffSAndreas Gohr $form->addTagOpen('table'); 52*f09444ffSAndreas Gohr $form->addTagOpen('tr'); 53*f09444ffSAndreas Gohr $form->addTagOpen('th'); 54*f09444ffSAndreas Gohr $form->addHTML($this->getLang('pattern')); 55*f09444ffSAndreas Gohr $form->addTagClose('th'); 56*f09444ffSAndreas Gohr $form->addTagOpen('th'); 57*f09444ffSAndreas Gohr $form->addHTML($this->getLang('assignees')); 58*f09444ffSAndreas Gohr $form->addTagClose('th'); 59*f09444ffSAndreas Gohr $form->addTagClose('tr'); 60*f09444ffSAndreas Gohr foreach ($assignments as $pattern => $assignees) { 61*f09444ffSAndreas Gohr $this->addRow($form, $pattern, $assignees); 62*f09444ffSAndreas Gohr } 63*f09444ffSAndreas Gohr $this->addRow($form, '', ''); 64*f09444ffSAndreas Gohr $form->addTagClose('table'); 65*f09444ffSAndreas Gohr 66*f09444ffSAndreas Gohr $form->addButton('save', $this->getLang('save')); 67*f09444ffSAndreas Gohr echo $form->toHTML(); 68*f09444ffSAndreas Gohr } 69*f09444ffSAndreas Gohr 70*f09444ffSAndreas Gohr /** 71*f09444ffSAndreas Gohr * @param Form $form 72*f09444ffSAndreas Gohr * @param string $pattern 73*f09444ffSAndreas Gohr * @param string $assignee 74*f09444ffSAndreas Gohr * @return void 75*f09444ffSAndreas Gohr */ 76*f09444ffSAndreas Gohr public function addRow($form, $pattern, $assignee) 77*f09444ffSAndreas Gohr { 78*f09444ffSAndreas Gohr static $row = 0; 79*f09444ffSAndreas Gohr 80*f09444ffSAndreas Gohr $form->addTagOpen('tr'); 81*f09444ffSAndreas Gohr $form->addTagOpen('td'); 82*f09444ffSAndreas Gohr $form->addTextInput("pattern[$row]")->val($pattern); 83*f09444ffSAndreas Gohr $form->addTagClose('td'); 84*f09444ffSAndreas Gohr $form->addTagOpen('td'); 85*f09444ffSAndreas Gohr $form->addTextInput("assignees[$row]")->val($assignee); 86*f09444ffSAndreas Gohr $form->addTagClose('td'); 87*f09444ffSAndreas Gohr $form->addTagClose('tr'); 88*f09444ffSAndreas Gohr $row++; 89*f09444ffSAndreas Gohr } 90*f09444ffSAndreas Gohr 91*f09444ffSAndreas Gohr /** @inheritDoc */ 92*f09444ffSAndreas Gohr public function getTOC() 93*f09444ffSAndreas Gohr { 94*f09444ffSAndreas Gohr return (new admin_plugin_acknowledge_report())->getTOC(); 95*f09444ffSAndreas Gohr } 96*f09444ffSAndreas Gohr 97*f09444ffSAndreas Gohr 98*f09444ffSAndreas Gohr} 99*f09444ffSAndreas Gohr 100