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