*/ class admin_plugin_tplinc extends DokuWiki_Admin_Plugin { /** @var helper_plugin_tplinc */ protected $helper; /** * admin_plugin_tplinc constructor. */ public function __construct() { $this->helper = plugin_load('helper', 'tplinc'); } /** * @return bool true if only access for superuser, false is for superusers and moderators */ public function forAdminOnly() { return true; } /** * Should carry out any processing required by the plugin. */ public function handle() { global $INPUT; if ($INPUT->str('action') == 'save' && checkSecurityToken()) { if ($this->helper->saveAssignments($INPUT->arr('a'))) { msg($this->getLang('saved'), 1); } } } /** * Render HTML output, e.g. helpful text and a form */ public function html() { global $ID; echo $this->locale_xhtml('intro'); echo '
'; echo ''; echo ''; echo ''; echo ''; // header echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; // existing assignments $assignments = $this->helper->loadAssignments(); $row = 0; foreach ($assignments as $assignment) { $this->assignmentRow($assignment, $row); $row++; } // three more rows for new ones for ($i = 0; $i < 3; $i++) { $this->assignmentRow(array('', '', '', ''), $row); $row++; } echo ''; // save button echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . $this->getLang('pattern') . '' . $this->getLang('page') . '' . $this->getLang('location') . '' . $this->getLang('skipacl') . '
'; echo '
'; echo $this->locale_xhtml('help'); } /** * One row in the table * * @param array $assignment * @param int $row the row counter */ protected function assignmentRow($assignment, $row) { list($pattern, $page, $location, $skipacl) = $assignment; echo ''; echo ''; echo ''; echo ''; $this->locationBox('a[x' . $row . '][2]', $location); echo ''; $checked = $skipacl ? 'checked="checked"' : ''; echo ''; echo ''; echo '' . inlineSVG(__DIR__ . '/drag.svg') . ''; echo ''; } /** * Create a dropdown for the locations * * @param string $name the parameter name * @param string $loc the current location value */ protected function locationBox($name, $loc) { $locations = null; if ($locations === null) $locations = $this->helper->getLocations(); if (!isset($locations[$loc])) $loc = ''; echo ''; } }