diff options
Diffstat (limited to 'lib/plugins/styling')
-rw-r--r-- | lib/plugins/styling/action.php | 25 | ||||
-rw-r--r-- | lib/plugins/styling/admin.php | 52 | ||||
-rw-r--r-- | lib/plugins/styling/popup.php | 4 |
3 files changed, 45 insertions, 36 deletions
diff --git a/lib/plugins/styling/action.php b/lib/plugins/styling/action.php index 46245ca75..39da86028 100644 --- a/lib/plugins/styling/action.php +++ b/lib/plugins/styling/action.php @@ -1,20 +1,24 @@ <?php + +use dokuwiki\Extension\ActionPlugin; +use dokuwiki\Extension\EventHandler; +use dokuwiki\Extension\Event; + /** * DokuWiki Plugin styling (Action Component) * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Andreas Gohr <andi@splitbrain.org> */ -class action_plugin_styling extends DokuWiki_Action_Plugin +class action_plugin_styling extends ActionPlugin { - /** * Registers a callback functions * - * @param Doku_Event_Handler $controller DokuWiki's event controller object + * @param EventHandler $controller DokuWiki's event controller object * @return void */ - public function register(Doku_Event_Handler $controller) + public function register(EventHandler $controller) { $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleHeader'); } @@ -22,12 +26,12 @@ class action_plugin_styling extends DokuWiki_Action_Plugin /** * Adds the preview parameter to the stylesheet loading in non-js mode * - * @param Doku_Event $event event object by reference - * @param mixed $param [the parameters passed as fifth argument to register_hook() when this - * handler was registered] + * @param Event $event event object by reference + * @param mixed $param [the parameters passed as fifth argument to register_hook() when this + * handler was registered] * @return void */ - public function handleHeader(Doku_Event &$event, $param) + public function handleHeader(Event &$event, $param) { global $ACT; global $INPUT; @@ -39,10 +43,11 @@ class action_plugin_styling extends DokuWiki_Action_Plugin // set preview $len = count($event->data['link']); for ($i = 0; $i < $len; $i++) { - if ($event->data['link'][$i]['rel'] == 'stylesheet' && + if ( + $event->data['link'][$i]['rel'] == 'stylesheet' && strpos($event->data['link'][$i]['href'], 'lib/exe/css.php') !== false ) { - $event->data['link'][$i]['href'] .= '&preview=1&tseed='.time(); + $event->data['link'][$i]['href'] .= '&preview=1&tseed=' . time(); } } } diff --git a/lib/plugins/styling/admin.php b/lib/plugins/styling/admin.php index 08c9afdc2..9fe4ebdba 100644 --- a/lib/plugins/styling/admin.php +++ b/lib/plugins/styling/admin.php @@ -1,13 +1,16 @@ <?php + +use dokuwiki\Extension\AdminPlugin; +use dokuwiki\StyleUtils; + /** * DokuWiki Plugin styling (Admin Component) * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Andreas Gohr <andi@splitbrain.org> */ -class admin_plugin_styling extends DokuWiki_Admin_Plugin +class admin_plugin_styling extends AdminPlugin { - public $ispopup = false; /** @@ -34,8 +37,8 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin global $INPUT; $run = $INPUT->extract('run')->str('run'); if (!$run) return; - if(!checkSecurityToken()) return; - $run = 'run'.ucfirst($run); + if (!checkSecurityToken()) return; + $run = 'run' . ucfirst($run); $this->$run(); } @@ -47,8 +50,8 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin $class = 'nopopup'; if ($this->ispopup) $class = 'ispopup page'; - echo '<div id="plugin__styling" class="'.$class.'">'; - ptln('<h1>'.$this->getLang('menu').'</h1>'); + echo '<div id="plugin__styling" class="' . $class . '">'; + echo '<h1>' . $this->getLang('menu') . '</h1>'; $this->form(); echo '</div>'; } @@ -61,22 +64,22 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin global $conf; global $ID; - $styleUtil = new \dokuwiki\StyleUtils($conf['template'], true, true); - $styleini = $styleUtil->cssStyleini(); + $styleUtil = new StyleUtils($conf['template'], true, true); + $styleini = $styleUtil->cssStyleini(); $replacements = $styleini['replacements']; if ($this->ispopup) { - $target = DOKU_BASE.'lib/plugins/styling/popup.php'; + $target = DOKU_BASE . 'lib/plugins/styling/popup.php'; } else { - $target = wl($ID, array('do' => 'admin', 'page' => 'styling')); + $target = wl($ID, ['do' => 'admin', 'page' => 'styling']); } if (empty($replacements)) { - echo '<p class="error">'.$this->getLang('error').'</p>'; + echo '<p class="error">' . $this->getLang('error') . '</p>'; } else { echo $this->locale_xhtml('intro'); - echo '<form class="styling" method="post" action="'.$target.'">'; + echo '<form class="styling" method="post" action="' . $target . '">'; formSecurityToken(); echo '<table><tbody>'; @@ -86,27 +89,28 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin if (empty($name)) $name = $key; echo '<tr>'; - echo '<td><label for="tpl__'.hsc($key).'">'.$name.'</label></td>'; - echo '<td><input type="'.$this->colorType($value).'" name="tpl['.hsc($key).']" id="tpl__'.hsc($key).'" - value="'.hsc($this->colorValue($value)).'" dir="ltr" required="required"/></td>'; + echo '<td><label for="tpl__' . hsc($key) . '">' . $name . '</label></td>'; + echo '<td><input type="' . $this->colorType($value) . '" name="tpl[' . hsc($key) . ']" ' . + 'id="tpl__' . hsc($key) . '" value="' . hsc($this->colorValue($value)) . '" ' . + 'dir="ltr" required="required"/></td>'; echo '</tr>'; } echo '</tbody></table>'; echo '<p>'; - echo '<button type="submit" name="run[preview]" class="btn_preview primary">'. - $this->getLang('btn_preview').'</button> '; + echo '<button type="submit" name="run[preview]" class="btn_preview primary">' . + $this->getLang('btn_preview') . '</button> '; #FIXME only if preview.ini exists: - echo '<button type="submit" name="run[reset]">'.$this->getLang('btn_reset').'</button>'; + echo '<button type="submit" name="run[reset]">' . $this->getLang('btn_reset') . '</button>'; echo '</p>'; echo '<p>'; - echo '<button type="submit" name="run[save]" class="primary">'.$this->getLang('btn_save').'</button>'; + echo '<button type="submit" name="run[save]" class="primary">' . $this->getLang('btn_save') . '</button>'; echo '</p>'; echo '<p>'; #FIXME only if local.ini exists: - echo '<button type="submit" name="run[revert]">'.$this->getLang('btn_revert').'</button>'; + echo '<button type="submit" name="run[revert]">' . $this->getLang('btn_revert') . '</button>'; echo '</p>'; echo '</form>'; @@ -150,7 +154,7 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin public function runPreview() { global $conf; - $ini = $conf['cachedir'].'/preview.ini'; + $ini = $conf['cachedir'] . '/preview.ini'; io_saveFile($ini, $this->makeini()); } @@ -160,7 +164,7 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin protected function runReset() { global $conf; - $ini = $conf['cachedir'].'/preview.ini'; + $ini = $conf['cachedir'] . '/preview.ini'; io_saveFile($ini, ''); } @@ -195,7 +199,7 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin $ini .= ";These overwrites have been generated from the Template styling Admin interface\n"; $ini .= ";Any values in this section will be overwritten by that tool again\n"; foreach ($INPUT->arr('tpl') as $key => $val) { - $ini .= $key.' = "'.addslashes($val).'"'."\n"; + $ini .= $key . ' = "' . addslashes($val) . '"' . "\n"; } return $ini; @@ -209,7 +213,7 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin protected function replaceIni($new) { global $conf; - $ini = DOKU_CONF."tpl/".$conf['template']."/style.ini"; + $ini = DOKU_CONF . "tpl/" . $conf['template'] . "/style.ini"; if (file_exists($ini)) { $old = io_readFile($ini); $old = preg_replace('/\[replacements\]\n.*?(\n\[.*]|$)/s', '\\1', $old); diff --git a/lib/plugins/styling/popup.php b/lib/plugins/styling/popup.php index 079062e43..0fef79ce3 100644 --- a/lib/plugins/styling/popup.php +++ b/lib/plugins/styling/popup.php @@ -1,6 +1,6 @@ <?php // phpcs:disable PSR1.Files.SideEffects -if (!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../../'); +if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../../'); require_once(DOKU_INC . 'inc/init.php'); //close session session_write_close(); @@ -23,7 +23,7 @@ $plugin->handle(); <title><?php echo $plugin->getLang('menu') ?></title> <?php tpl_metaheaders(false) ?> <meta name="viewport" content="width=device-width,initial-scale=1" /> - <?php echo tpl_favicon(array('favicon')) ?> + <?php echo tpl_favicon(['favicon']) ?> </head> <body class="dokuwiki"> <?php $plugin->html() ?> |