Warning: Cannot modify header information - headers already sent by (output started at /var/www/jonas-eriksen.dk/pic/private/index.php:1) in /var/www/jonas-eriksen.dk/pic/private/index.php on line 215
PK ! ñö/ôE E Event.phpnu „[µü¤ name = $name;
$this->data =& $data;
}
/**
* @return string
*/
public function __toString()
{
return $this->name;
}
/**
* advise all registered BEFORE handlers of this event
*
* if these methods are used by functions outside of this object, they must
* properly handle correct processing of any default action and issue an
* advise_after() signal. e.g.
* $evt = new dokuwiki\Plugin\Doku_Event(name, data);
* if ($evt->advise_before(canPreventDefault) {
* // default action code block
* }
* $evt->advise_after();
* unset($evt);
*
* @param bool $enablePreventDefault
* @return bool results of processing the event, usually $this->runDefault
*/
public function advise_before($enablePreventDefault = true)
{
global $EVENT_HANDLER;
$this->canPreventDefault = $enablePreventDefault;
if ($EVENT_HANDLER !== null) {
$EVENT_HANDLER->process_event($this, 'BEFORE');
} else {
dbglog($this->name . ':BEFORE event triggered before event system was initialized');
}
return (!$enablePreventDefault || $this->runDefault);
}
/**
* advise all registered AFTER handlers of this event
*
* @param bool $enablePreventDefault
* @see advise_before() for details
*/
public function advise_after()
{
global $EVENT_HANDLER;
$this->mayContinue = true;
if ($EVENT_HANDLER !== null) {
$EVENT_HANDLER->process_event($this, 'AFTER');
} else {
dbglog($this->name . ':AFTER event triggered before event system was initialized');
}
}
/**
* trigger
*
* - advise all registered (_BEFORE) handlers that this event is about to take place
* - carry out the default action using $this->data based on $enablePrevent and
* $this->_default, all of which may have been modified by the event handlers.
* - advise all registered (_AFTER) handlers that the event has taken place
*
* @param null|callable $action
* @param bool $enablePrevent
* @return mixed $event->results
* the value set by any _before or handlers if the default action is prevented
* or the results of the default action (as modified by _after handlers)
* or NULL no action took place and no handler modified the value
*/
public function trigger($action = null, $enablePrevent = true)
{
if (!is_callable($action)) {
$enablePrevent = false;
if ($action !== null) {
trigger_error(
'The default action of ' . $this .
' is not null but also not callable. Maybe the method is not public?',
E_USER_WARNING
);
}
}
if ($this->advise_before($enablePrevent) && is_callable($action)) {
$this->result = call_user_func_array($action, [&$this->data]);
}
$this->advise_after();
return $this->result;
}
/**
* stopPropagation
*
* stop any further processing of the event by event handlers
* this function does not prevent the default action taking place
*/
public function stopPropagation()
{
$this->mayContinue = false;
}
/**
* may the event propagate to the next handler?
*
* @return bool
*/
public function mayPropagate()
{
return $this->mayContinue;
}
/**
* preventDefault
*
* prevent the default action taking place
*/
public function preventDefault()
{
$this->runDefault = false;
}
/**
* should the default action be executed?
*
* @return bool
*/
public function mayRunDefault()
{
return $this->runDefault;
}
/**
* Convenience method to trigger an event
*
* Creates, triggers and destroys an event in one go
*
* @param string $name name for the event
* @param mixed $data event data
* @param callable $action (optional, default=NULL) default action, a php callback function
* @param bool $canPreventDefault (optional, default=true) can hooks prevent the default action
*
* @return mixed the event results value after all event processing is complete
* by default this is the return value of the default action however
* it can be set or modified by event handler hooks
*/
static public function createAndTrigger($name, &$data, $action = null, $canPreventDefault = true)
{
$evt = new Event($name, $data);
return $evt->trigger($action, $canPreventDefault);
}
}
PK ! s‰´×I I SyntaxPlugin.phpnu „[µü¤
*/
abstract class SyntaxPlugin extends \dokuwiki\Parsing\ParserMode\Plugin
{
use PluginTrait;
protected $allowedModesSetup = false;
/**
* Syntax Type
*
* Needs to return one of the mode types defined in $PARSER_MODES in Parser.php
*
* @return string
*/
abstract public function getType();
/**
* Allowed Mode Types
*
* Defines the mode types for other dokuwiki markup that maybe nested within the
* plugin's own markup. Needs to return an array of one or more of the mode types
* defined in $PARSER_MODES in Parser.php
*
* @return array
*/
public function getAllowedTypes()
{
return array();
}
/**
* Paragraph Type
*
* Defines how this syntax is handled regarding paragraphs. This is important
* for correct XHTML nesting. Should return one of the following:
*
* 'normal' - The plugin can be used inside paragraphs
* 'block' - Open paragraphs need to be closed before plugin output
* 'stack' - Special case. Plugin wraps other paragraphs.
*
* @see Doku_Handler_Block
*
* @return string
*/
public function getPType()
{
return 'normal';
}
/**
* Handler to prepare matched data for the rendering process
*
* This function can only pass data to render() via its return value - render()
* may be not be run during the object's current life.
*
* Usually you should only need the $match param.
*
* @param string $match The text matched by the patterns
* @param int $state The lexer state for the match
* @param int $pos The character position of the matched text
* @param Doku_Handler $handler The Doku_Handler object
* @return bool|array Return an array with all data you want to use in render, false don't add an instruction
*/
abstract public function handle($match, $state, $pos, Doku_Handler $handler);
/**
* Handles the actual output creation.
*
* The function must not assume any other of the classes methods have been run
* during the object's current life. The only reliable data it receives are its
* parameters.
*
* The function should always check for the given output format and return false
* when a format isn't supported.
*
* $renderer contains a reference to the renderer object which is
* currently handling the rendering. You need to use it for writing
* the output. How this is done depends on the renderer used (specified
* by $format
*
* The contents of the $data array depends on what the handler() function above
* created
*
* @param string $format output format being rendered
* @param Doku_Renderer $renderer the current renderer object
* @param array $data data created by handler()
* @return boolean rendered correctly? (however, returned value is not used at the moment)
*/
abstract public function render($format, Doku_Renderer $renderer, $data);
/**
* There should be no need to override this function
*
* @param string $mode
* @return bool
*/
public function accepts($mode)
{
if (!$this->allowedModesSetup) {
global $PARSER_MODES;
$allowedModeTypes = $this->getAllowedTypes();
foreach ($allowedModeTypes as $mt) {
$this->allowedModes = array_merge($this->allowedModes, $PARSER_MODES[$mt]);
}
$idx = array_search(substr(get_class($this), 7), (array)$this->allowedModes);
if ($idx !== false) {
unset($this->allowedModes[$idx]);
}
$this->allowedModesSetup = true;
}
return parent::accepts($mode);
}
}
PK ! UÿòhÀ À
Plugin.phpnu „[µü¤
*/
abstract class AdminPlugin extends Plugin
{
/**
* Return the text that is displayed at the main admin menu
* (Default localized language string 'menu' is returned, override this function for setting another name)
*
* @param string $language language code
* @return string menu string
*/
public function getMenuText($language)
{
$menutext = $this->getLang('menu');
if (!$menutext) {
$info = $this->getInfo();
$menutext = $info['name'] . ' ...';
}
return $menutext;
}
/**
* Return the path to the icon being displayed in the main admin menu.
* By default it tries to find an 'admin.svg' file in the plugin directory.
* (Override this function for setting another image)
*
* Important: you have to return a single path, monochrome SVG icon! It has to be
* under 2 Kilobytes!
*
* We recommend icons from https://materialdesignicons.com/ or to use a matching
* style.
*
* @return string full path to the icon file
*/
public function getMenuIcon()
{
$plugin = $this->getPluginName();
return DOKU_PLUGIN . $plugin . '/admin.svg';
}
/**
* Determine position in list in admin window
* Lower values are sorted up
*
* @return int
*/
public function getMenuSort()
{
return 1000;
}
/**
* Carry out required processing
*/
public function handle()
{
// some plugins might not need this
}
/**
* Output html of the admin page
*/
abstract public function html();
/**
* Checks if access should be granted to this admin plugin
*
* @return bool true if the current user may access this admin plugin
*/
public function isAccessibleByCurrentUser() {
$data = [];
$data['instance'] = $this;
$data['hasAccess'] = false;
$event = new Event('ADMINPLUGIN_ACCESS_CHECK', $data);
if($event->advise_before()) {
if ($this->forAdminOnly()) {
$data['hasAccess'] = auth_isadmin();
} else {
$data['hasAccess'] = auth_ismanager();
}
}
$event->advise_after();
return $data['hasAccess'];
}
/**
* Return true for access only by admins (config:superuser) or false if managers are allowed as well
*
* @return bool
*/
public function forAdminOnly()
{
return true;
}
/**
* Return array with ToC items. Items can be created with the html_mktocitem()
*
* @see html_mktocitem()
* @see tpl_toc()
*
* @return array
*/
public function getTOC()
{
return array();
}
}
PK ! 1}nÞ Þ ActionPlugin.phpnu „[µü¤
*/
abstract class ActionPlugin extends Plugin
{
/**
* Registers a callback function for a given event
*
* @param \Doku_Event_Handler $controller
*/
abstract public function register(\Doku_Event_Handler $controller);
}
PK ! L
J. . PluginTrait.phpnu „[µü¤ getLang()
protected $configloaded = false; // set to true by loadConfig() after loading plugin configuration variables
protected $conf = array(); // array to hold plugin settings, best accessed via ->getConf()
/**
* @see PluginInterface::getInfo()
*/
public function getInfo()
{
$parts = explode('_', get_class($this));
$info = DOKU_PLUGIN . '/' . $parts[2] . '/plugin.info.txt';
if (file_exists($info)) return confToHash($info);
msg(
'getInfo() not implemented in ' . get_class($this) . ' and ' . $info . ' not found.
' .
'Verify you\'re running the latest version of the plugin. If the problem persists, send a ' .
'bug report to the author of the ' . $parts[2] . ' plugin.', -1
);
return array(
'date' => '0000-00-00',
'name' => $parts[2] . ' plugin',
);
}
/**
* @see PluginInterface::isSingleton()
*/
public function isSingleton()
{
return true;
}
/**
* @see PluginInterface::loadHelper()
*/
public function loadHelper($name, $msg = true)
{
$obj = plugin_load('helper', $name);
if (is_null($obj) && $msg) msg("Helper plugin $name is not available or invalid.", -1);
return $obj;
}
// region introspection methods
/**
* @see PluginInterface::getPluginType()
*/
public function getPluginType()
{
list($t) = explode('_', get_class($this), 2);
return $t;
}
/**
* @see PluginInterface::getPluginName()
*/
public function getPluginName()
{
list(/* $t */, /* $p */, $n) = explode('_', get_class($this), 4);
return $n;
}
/**
* @see PluginInterface::getPluginComponent()
*/
public function getPluginComponent()
{
list(/* $t */, /* $p */, /* $n */, $c) = explode('_', get_class($this), 4);
return (isset($c) ? $c : '');
}
// endregion
// region localization methods
/**
* @see PluginInterface::getLang()
*/
public function getLang($id)
{
if (!$this->localised) $this->setupLocale();
return (isset($this->lang[$id]) ? $this->lang[$id] : '');
}
/**
* @see PluginInterface::locale_xhtml()
*/
public function locale_xhtml($id)
{
return p_cached_output($this->localFN($id));
}
/**
* @see PluginInterface::localFN()
*/
public function localFN($id, $ext = 'txt')
{
global $conf;
$plugin = $this->getPluginName();
$file = DOKU_CONF . 'plugin_lang/' . $plugin . '/' . $conf['lang'] . '/' . $id . '.' . $ext;
if (!file_exists($file)) {
$file = DOKU_PLUGIN . $plugin . '/lang/' . $conf['lang'] . '/' . $id . '.' . $ext;
if (!file_exists($file)) {
//fall back to english
$file = DOKU_PLUGIN . $plugin . '/lang/en/' . $id . '.' . $ext;
}
}
return $file;
}
/**
* @see PluginInterface::setupLocale()
*/
public function setupLocale()
{
if ($this->localised) return;
global $conf, $config_cascade; // definitely don't invoke "global $lang"
$path = DOKU_PLUGIN . $this->getPluginName() . '/lang/';
$lang = array();
// don't include once, in case several plugin components require the same language file
@include($path . 'en/lang.php');
foreach ($config_cascade['lang']['plugin'] as $config_file) {
if (file_exists($config_file . $this->getPluginName() . '/en/lang.php')) {
include($config_file . $this->getPluginName() . '/en/lang.php');
}
}
if ($conf['lang'] != 'en') {
@include($path . $conf['lang'] . '/lang.php');
foreach ($config_cascade['lang']['plugin'] as $config_file) {
if (file_exists($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php')) {
include($config_file . $this->getPluginName() . '/' . $conf['lang'] . '/lang.php');
}
}
}
$this->lang = $lang;
$this->localised = true;
}
// endregion
// region configuration methods
/**
* @see PluginInterface::getConf()
*/
public function getConf($setting, $notset = false)
{
if (!$this->configloaded) {
$this->loadConfig();
}
if (isset($this->conf[$setting])) {
return $this->conf[$setting];
} else {
return $notset;
}
}
/**
* @see PluginInterface::loadConfig()
*/
public function loadConfig()
{
global $conf;
$defaults = $this->readDefaultSettings();
$plugin = $this->getPluginName();
foreach ($defaults as $key => $value) {
if (isset($conf['plugin'][$plugin][$key])) continue;
$conf['plugin'][$plugin][$key] = $value;
}
$this->configloaded = true;
$this->conf =& $conf['plugin'][$plugin];
}
/**
* read the plugin's default configuration settings from conf/default.php
* this function is automatically called through getConf()
*
* @return array setting => value
*/
protected function readDefaultSettings()
{
$path = DOKU_PLUGIN . $this->getPluginName() . '/conf/';
$conf = array();
if (file_exists($path . 'default.php')) {
include($path . 'default.php');
}
return $conf;
}
// endregion
// region output methods
/**
* @see PluginInterface::email()
*/
public function email($email, $name = '', $class = '', $more = '')
{
if (!$email) return $name;
$email = obfuscate($email);
if (!$name) $name = $email;
$class = "class='" . ($class ? $class : 'mail') . "'";
return "$name";
}
/**
* @see PluginInterface::external_link()
*/
public function external_link($link, $title = '', $class = '', $target = '', $more = '')
{
global $conf;
$link = htmlentities($link);
if (!$title) $title = $link;
if (!$target) $target = $conf['target']['extern'];
if ($conf['relnofollow']) $more .= ' rel="nofollow"';
if ($class) $class = " class='$class'";
if ($target) $target = " target='$target'";
if ($more) $more = " " . trim($more);
return "$title";
}
/**
* @see PluginInterface::render_text()
*/
public function render_text($text, $format = 'xhtml')
{
return p_render($format, p_get_instructions($text), $info);
}
// endregion
}
PK ! )p}„V
V
RemotePlugin.phpnu „[µü¤ api = new Api();
}
/**
* Get all available methods with remote access.
*
* By default it exports all public methods of a remote plugin. Methods beginning
* with an underscore are skipped.
*
* @return array Information about all provided methods. {@see dokuwiki\Remote\RemoteAPI}.
* @throws ReflectionException
*/
public function _getMethods()
{
$result = array();
$reflection = new \ReflectionClass($this);
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
// skip parent methods, only methods further down are exported
$declaredin = $method->getDeclaringClass()->name;
if ($declaredin === 'dokuwiki\Extension\Plugin' || $declaredin === 'dokuwiki\Extension\RemotePlugin') {
continue;
}
$method_name = $method->name;
if (strpos($method_name, '_') === 0) {
continue;
}
// strip asterisks
$doc = $method->getDocComment();
$doc = preg_replace(
array('/^[ \t]*\/\*+[ \t]*/m', '/[ \t]*\*+[ \t]*/m', '/\*+\/\s*$/m', '/\s*\/\s*$/m'),
array('', '', '', ''),
$doc
);
// prepare data
$data = array();
$data['name'] = $method_name;
$data['public'] = 0;
$data['doc'] = $doc;
$data['args'] = array();
// get parameter type from doc block type hint
foreach ($method->getParameters() as $parameter) {
$name = $parameter->name;
$type = 'string'; // we default to string
if (preg_match('/^@param[ \t]+([\w|\[\]]+)[ \t]\$' . $name . '/m', $doc, $m)) {
$type = $this->cleanTypeHint($m[1]);
}
$data['args'][] = $type;
}
// get return type from doc block type hint
if (preg_match('/^@return[ \t]+([\w|\[\]]+)/m', $doc, $m)) {
$data['return'] = $this->cleanTypeHint($m[1]);
} else {
$data['return'] = 'string';
}
// add to result
$result[$method_name] = $data;
}
return $result;
}
/**
* Matches the given type hint against the valid options for the remote API
*
* @param string $hint
* @return string
*/
protected function cleanTypeHint($hint)
{
$types = explode('|', $hint);
foreach ($types as $t) {
if (substr($t, -2) === '[]') {
return 'array';
}
if ($t === 'boolean') {
return 'bool';
}
if (in_array($t, array('array', 'string', 'int', 'double', 'bool', 'null', 'date', 'file'))) {
return $t;
}
}
return 'string';
}
/**
* @return Api
*/
protected function getApi()
{
return $this->api;
}
}
PK ! Abӌ<