code style: operator spacing

This commit is contained in:
Andreas Gohr 2023-08-31 22:38:07 +02:00
parent 7a08a8bc85
commit 90fb952c4c
85 changed files with 1438 additions and 1410 deletions

View File

@ -17,8 +17,6 @@
<exclude name="PSR12.Classes.OpeningBraceSpace.Found"/>
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceBefore"/>
<exclude name="PSR12.Operators.OperatorSpacing.NoSpaceAfter"/>
</rule>
<!-- for now we mix declarations and execution here (mostly for defines) -->

View File

@ -136,7 +136,7 @@ class PageCLI extends CLI
$options->registerArgument(
'key',
'The name of the metadata item to be retrieved.' . "\n" .
'If empty, an array of all the metadata items is returned.' ."\n" .
'If empty, an array of all the metadata items is returned.' . "\n" .
'For retrieving items that are stored in sub-arrays, separate the ' .
'keys of the different levels by spaces, in quotes, eg "date modified".',
false,

View File

@ -3,7 +3,6 @@
namespace dokuwiki\Action;
use dokuwiki\Ui\Editor;
use dokuwiki\Ui;
/**
* Class Locked
@ -30,9 +29,9 @@ class Locked extends AbstractAction
/**
* Display error on locked pages
*
* @return void
* @author Andreas Gohr <andi@splitbrain.org>
*
* @return void
*/
public function showBanner()
{
@ -43,14 +42,16 @@ class Locked extends AbstractAction
$locktime = filemtime(wikiLockFN($ID));
$expire = dformat($locktime + $conf['locktime']);
$min = round(($conf['locktime'] - (time() - $locktime) )/60);
$min = round(($conf['locktime'] - (time() - $locktime)) / 60);
// print intro
echo p_locale_xhtml('locked');
echo '<ul>';
echo '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>';
echo '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>';
echo '</ul>'.DOKU_LF;
echo '<li><div class="li"><strong>' . $lang['lockedby'] . '</strong> ' .
editorinfo($INFO['locked']) . '</div></li>';
echo '<li><div class="li"><strong>' . $lang['lockexpire'] . '</strong> ' .
$expire . ' (' . $min . ' min)</div></li>';
echo '</ul>' . DOKU_LF;
}
}

View File

@ -82,7 +82,7 @@ class Resendpwd extends AbstractAclAction
if ($token) {
// we're in token phase - get user info from token
$tfile = $conf['cachedir'] .'/'. $token[0] .'/'. $token . '.pwauth';
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
$INPUT->remove('pwauth');
@ -154,7 +154,7 @@ class Resendpwd extends AbstractAclAction
// generate auth token
$token = md5(auth_randombytes(16)); // random secret
$tfile = $conf['cachedir'] .'/'. $token[0] .'/'. $token .'.pwauth';
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', ['do' => 'resendpwd', 'pwauth' => $token], true, '&');
io_saveFile($tfile, $user);
@ -167,7 +167,7 @@ class Resendpwd extends AbstractAclAction
];
$mail = new \Mailer();
$mail->to($userinfo['name'] .' <'. $userinfo['mail'] .'>');
$mail->to($userinfo['name'] . ' <' . $userinfo['mail'] . '>');
$mail->subject($lang['regpwmail']);
$mail->setBody($text, $trep);
if ($mail->send()) {

View File

@ -510,7 +510,7 @@ abstract class ChangeLog
// add a possible revision of external edit, create or deletion
if (
$lastTail == $eof && $afterCount <= (int) ($max / 2) &&
count($revs) && !$this->isCurrentRevision($revs[count($revs)-1])
count($revs) && !$this->isCurrentRevision($revs[count($revs) - 1])
) {
$revs[] = $this->currentRevision;
$afterCount++;
@ -607,12 +607,12 @@ abstract class ChangeLog
// externally deleted, set revision date as late as possible
$revInfo = [
'date' => max($lastRev +1, time() -1), // 1 sec before now or new page save
'date' => max($lastRev + 1, time() - 1), // 1 sec before now or new page save
'ip' => '127.0.0.1',
'type' => DOKU_CHANGE_TYPE_DELETE,
'id' => $this->id,
'user' => '',
'sum' => $lang['deleted'].' - '.$lang['external_edit'].' ('.$lang['unknowndate'].')',
'sum' => $lang['deleted'] . ' - ' . $lang['external_edit'] . ' (' . $lang['unknowndate'] . ')',
'extra' => '',
'sizechange' => -io_getSizeFile($this->getFilename($lastRev)),
'timestamp' => false,
@ -629,23 +629,23 @@ abstract class ChangeLog
if ($isJustCreated) {
$timestamp = $fileRev;
$sum = $lang['created'].' - '.$lang['external_edit'];
$sum = $lang['created'] . ' - ' . $lang['external_edit'];
} elseif ($fileRev > $lastRev) {
$timestamp = $fileRev;
$sum = $lang['external_edit'];
} else {
// $fileRev is older than $lastRev, that is erroneous/incorrect occurrence.
$msg = "Warning: current file modification time is older than last revision date";
$details = 'File revision: '.$fileRev.' '.dformat($fileRev, "%Y-%m-%d %H:%M:%S")."\n"
.'Last revision: '.$lastRev.' '.dformat($lastRev, "%Y-%m-%d %H:%M:%S");
$details = 'File revision: ' . $fileRev . ' ' . dformat($fileRev, "%Y-%m-%d %H:%M:%S") . "\n"
. 'Last revision: ' . $lastRev . ' ' . dformat($lastRev, "%Y-%m-%d %H:%M:%S");
Logger::error($msg, $details, $this->getFilename());
$timestamp = false;
$sum = $lang['external_edit'].' ('.$lang['unknowndate'].')';
$sum = $lang['external_edit'] . ' (' . $lang['unknowndate'] . ')';
}
// externally created or edited
$revInfo = [
'date' => $timestamp ?: $lastRev +1,
'date' => $timestamp ?: $lastRev + 1,
'ip' => '127.0.0.1',
'type' => $isJustCreated ? DOKU_CHANGE_TYPE_CREATE : DOKU_CHANGE_TYPE_EDIT,
'id' => $this->id,

View File

@ -111,7 +111,7 @@ class RevisionInfo
return media_printicon($id);
} elseif ($this->val('mode') == 'page') {
// page revision
return '<img class="icon" src="'.DOKU_BASE.'lib/images/fileicons/file.png" alt="'.$id.'" />';
return '<img class="icon" src="' . DOKU_BASE . 'lib/images/fileicons/file.png" alt="' . $id . '" />';
}
}
@ -130,7 +130,7 @@ class RevisionInfo
// when unknown, alter formatted string "YYYY-mm-DD HH:MM" to "____-__-__ __:__"
$formatted = preg_replace('/[0-9a-zA-Z]/', '_', $formatted);
}
return '<span class="date">'. $formatted .'</span>';
return '<span class="date">' . $formatted . '</span>';
}
/**
@ -141,7 +141,7 @@ class RevisionInfo
*/
public function showEditSummary()
{
return '<span class="sum">'.' '. hsc($this->val('sum')).'</span>';
return '<span class="sum">' . ' ' . hsc($this->val('sum')) . '</span>';
}
/**
@ -153,12 +153,12 @@ class RevisionInfo
public function showEditor()
{
if ($this->val('user')) {
$html = '<bdi>'. editorinfo($this->val('user')) .'</bdi>';
if (auth_ismanager()) $html .= ' <bdo dir="ltr">('. $this->val('ip') .')</bdo>';
$html = '<bdi>' . editorinfo($this->val('user')) . '</bdi>';
if (auth_ismanager()) $html .= ' <bdo dir="ltr">(' . $this->val('ip') . ')</bdo>';
} else {
$html = '<bdo dir="ltr">'. $this->val('ip') .'</bdo>';
$html = '<bdo dir="ltr">' . $this->val('ip') . '</bdo>';
}
return '<span class="user">'. $html. '</span>';
return '<span class="user">' . $html . '</span>';
}
/**
@ -174,14 +174,14 @@ class RevisionInfo
if ($this->val('mode') == 'media') {
// media file revision
$params = ['tab_details'=> 'view', 'ns'=> getNS($id), 'image'=> $id];
if ($rev) $params += ['rev'=> $rev];
$params = ['tab_details' => 'view', 'ns' => getNS($id), 'image' => $id];
if ($rev) $params += ['rev' => $rev];
$href = media_managerURL($params, '&');
$display_name = $id;
$exists = file_exists(mediaFN($id, $rev));
} elseif ($this->val('mode') == 'page') {
// page revision
$params = $rev ? ['rev'=> $rev] : [];
$params = $rev ? ['rev' => $rev] : [];
$href = wl($id, $params, false, '&');
$display_name = useHeading('navigation') ? hsc(p_get_first_heading($id)) : $id;
if (!$display_name) $display_name = $id;
@ -200,7 +200,7 @@ class RevisionInfo
if ($this->val('type') == DOKU_CHANGE_TYPE_DELETE) {
$class = 'wikilink2';
}
return '<a href="'.$href.'" class="'.$class.'">'.$display_name.'</a>';
return '<a href="' . $href . '" class="' . $class . '">' . $display_name . '</a>';
}
/**
@ -216,7 +216,7 @@ class RevisionInfo
$id = $this->val('id');
$rev = $this->isCurrent() ? '' : $this->val('date');
$params = ($rev) ? ['rev'=> $rev] : [];
$params = ($rev) ? ['rev' => $rev] : [];
// revision info may have timestamp key when external edits occurred
$date = ($this->val('timestamp') === false)
@ -240,12 +240,12 @@ class RevisionInfo
$class = 'wikilink2';
} else {
//revision is not in attic
return $id.' ['.$date.']';
return $id . ' [' . $date . ']';
}
if ($this->val('type') == DOKU_CHANGE_TYPE_DELETE) {
$class = 'wikilink2';
}
return '<bdi><a class="'.$class.'" href="'.$href.'">'.$id.' ['.$date.']'.'</a></bdi>';
return '<bdi><a class="' . $class . '" href="' . $href . '">' . $id . ' [' . $date . ']' . '</a></bdi>';
}
/**
@ -268,7 +268,7 @@ class RevisionInfo
$revs = (new MediaChangeLog($id))->getRevisions(0, 1);
$showLink = (count($revs) && file_exists(mediaFN($id, $revs[0])) && file_exists(mediaFN($id)));
if ($showLink) {
$param = ['tab_details'=>'history', 'mediado'=>'diff', 'ns'=> getNS($id), 'image'=> $id];
$param = ['tab_details' => 'history', 'mediado' => 'diff', 'ns' => getNS($id), 'image' => $id];
$href = media_managerURL($param, '&');
}
} elseif ($this->val('mode') == 'page') {
@ -276,17 +276,17 @@ class RevisionInfo
// when a page just created anyway, it is natural to expect no older revisions
// even if it had once existed but deleted before. Simply ignore to check changelog.
if ($this->val('type') !== DOKU_CHANGE_TYPE_CREATE) {
$href = wl($id, ['do'=>'diff'], false, '&');
$href = wl($id, ['do' => 'diff'], false, '&');
}
}
if ($href) {
return '<a href="'.$href.'" class="diff_link">'
.'<img src="'.DOKU_BASE.'lib/images/diff.png" width="15" height="11"'
.' title="'. $lang['diff'] .'" alt="'.$lang['diff'] .'" />'
.'</a>';
return '<a href="' . $href . '" class="diff_link">'
. '<img src="' . DOKU_BASE . 'lib/images/diff.png" width="15" height="11"'
. ' title="' . $lang['diff'] . '" alt="' . $lang['diff'] . '" />'
. '</a>';
} else {
return '<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />';
return '<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />';
}
}
@ -306,23 +306,23 @@ class RevisionInfo
if ($this->val('mode') == 'media') {
// media file revision
if (!$this->isCurrent() && file_exists(mediaFN($id, $rev))) {
$param = ['mediado'=>'diff', 'image'=> $id, 'rev'=> $rev];
$param = ['mediado' => 'diff', 'image' => $id, 'rev' => $rev];
$href = media_managerURL($param, '&');
}
} elseif ($this->val('mode') == 'page') {
// page revision
if (!$this->isCurrent()) {
$href = wl($id, ['rev'=> $rev, 'do'=>'diff'], false, '&');
$href = wl($id, ['rev' => $rev, 'do' => 'diff'], false, '&');
}
}
if ($href) {
return '<a href="'.$href.'" class="diff_link">'
.'<img src="'.DOKU_BASE.'lib/images/diff.png" width="15" height="11"'
.' title="'. $lang['diff'] .'" alt="'.$lang['diff'] .'" />'
.'</a>';
return '<a href="' . $href . '" class="diff_link">'
. '<img src="' . DOKU_BASE . 'lib/images/diff.png" width="15" height="11"'
. ' title="' . $lang['diff'] . '" alt="' . $lang['diff'] . '" />'
. '</a>';
} else {
return '<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />';
return '<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />';
}
}
@ -343,15 +343,15 @@ class RevisionInfo
$id = $this->val('id');
if ($this->val('mode') == 'media') {
// media file revision
$param = ['tab_details'=>'history', 'ns'=> getNS($id), 'image'=> $id];
$param = ['tab_details' => 'history', 'ns' => getNS($id), 'image' => $id];
$href = media_managerURL($param, '&');
} elseif ($this->val('mode') == 'page') {
// page revision
$href = wl($id, ['do'=>'revisions'], false, '&');
$href = wl($id, ['do' => 'revisions'], false, '&');
}
return '<a href="'.$href.'" class="revisions_link">'
. '<img src="'.DOKU_BASE.'lib/images/history.png" width="12" height="14"'
. ' title="'.$lang['btn_revs'].'" alt="'.$lang['btn_revs'].'" />'
return '<a href="' . $href . '" class="revisions_link">'
. '<img src="' . DOKU_BASE . 'lib/images/history.png" width="12" height="14"'
. ' title="' . $lang['btn_revs'] . '" alt="' . $lang['btn_revs'] . '" />'
. '</a>';
}
@ -374,7 +374,7 @@ class RevisionInfo
} else {
$value = '±' . $value;
}
return '<span class="'.$class.'">'.$value.'</span>';
return '<span class="' . $class . '">' . $value . '</span>';
}
/**
@ -386,6 +386,6 @@ class RevisionInfo
public function showCurrentIndicator()
{
global $lang;
return $this->isCurrent() ? '('.$lang['current'].')' : '';
return $this->isCurrent() ? '(' . $lang['current'] . ')' : '';
}
}

View File

@ -43,7 +43,7 @@ class ErrorHandler
register_shutdown_function([ErrorHandler::class, 'fatalShutdown']);
set_error_handler(
[ErrorHandler::class, 'errorHandler'],
E_WARNING|E_USER_ERROR|E_USER_WARNING|E_RECOVERABLE_ERROR
E_WARNING | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR
);
}
}

View File

@ -154,7 +154,7 @@ class MediaFile
*/
public function userPermission()
{
return auth_quickaclcheck(getNS($this->id).':*');
return auth_quickaclcheck(getNS($this->id) . ':*');
}
/** @return JpegMeta */

View File

@ -210,7 +210,7 @@ class PageFile
$this->updateMetadata($logEntry);
// update the purgefile (timestamp of the last time anything within the wiki was changed)
io_saveFile($conf['cachedir'].'/purgefile', time());
io_saveFile($conf['cachedir'] . '/purgefile', time());
return $data;
}
@ -238,12 +238,12 @@ class PageFile
if (touch($fileLastMod, $revInfo['date'])) {
clearstatcache();
$msg = "PageFile($this->id)::detectExternalEdit(): timestamp successfully modified";
$details = '('.$wrong_timestamp.' -> '.$revInfo['date'].')';
$details = '(' . $wrong_timestamp . ' -> ' . $revInfo['date'] . ')';
Logger::error($msg, $details, $fileLastMod);
} else {
// runtime error
$msg = "PageFile($this->id)::detectExternalEdit(): page file should be newer than last revision "
.'('.filemtime($fileLastMod).' < '. $this->changelog->lastRevision() .')';
. '(' . filemtime($fileLastMod) . ' < ' . $this->changelog->lastRevision() . ')';
throw new RuntimeException($msg);
}
}

View File

@ -31,6 +31,6 @@ class ButtonElement extends Element
*/
public function toHTML()
{
return '<button ' . buildAttributes($this->attrs(), true) . '>'.$this->content.'</button>';
return '<button ' . buildAttributes($this->attrs(), true) . '>' . $this->content . '</button>';
}
}

View File

@ -71,10 +71,10 @@ class CheckableElement extends InputElement
public function toHTML()
{
if ($this->label) {
return '<label '. buildAttributes($this->label->attrs()) .'>'.DOKU_LF
. $this->mainElementHTML() .DOKU_LF
.'<span>'. $this->label->val() .'</span>'.DOKU_LF
.'</label>';
return '<label ' . buildAttributes($this->label->attrs()) . '>' . DOKU_LF
. $this->mainElementHTML() . DOKU_LF
. '<span>' . $this->label->val() . '</span>' . DOKU_LF
. '</label>';
} else {
return $this->mainElementHTML();
}

View File

@ -32,9 +32,9 @@ class FieldsetOpenElement extends TagOpenElement
*/
public function toHTML()
{
$html = '<fieldset '.buildAttributes($this->attrs()).'>';
$html = '<fieldset ' . buildAttributes($this->attrs()) . '>';
$legend = $this->val();
if ($legend) $html .= DOKU_LF.'<legend>'.hsc($legend).'</legend>';
if ($legend) $html .= DOKU_LF . '<legend>' . hsc($legend) . '</legend>';
return $html;
}
}

View File

@ -478,14 +478,14 @@ class Form extends Element
// trigger event to provide an opportunity to modify this form
if (isset($eventName)) {
$eventName = 'FORM_'.strtoupper($eventName).'_OUTPUT';
$eventName = 'FORM_' . strtoupper($eventName) . '_OUTPUT';
Event::createAndTrigger($eventName, $this, null, false);
}
$html = '<form '. buildAttributes($this->attrs()) .'>';
$html = '<form ' . buildAttributes($this->attrs()) . '>';
foreach ($this->hidden as $name => $value) {
$html .= '<input type="hidden" name="'. $name .'" value="'. formText($value) .'" />';
$html .= '<input type="hidden" name="' . $name . '" value="' . formText($value) . '" />';
}
foreach ($this->elements as $element) {

View File

@ -148,7 +148,7 @@ class InputElement extends Element
protected function mainElementHTML()
{
if ($this->useInput) $this->prefillInput();
return '<input '. buildAttributes($this->attrs()) .' />';
return '<input ' . buildAttributes($this->attrs()) . ' />';
}
/**
@ -159,10 +159,10 @@ class InputElement extends Element
public function toHTML()
{
if ($this->label) {
return '<label '. buildAttributes($this->label->attrs()) .'>'.DOKU_LF
.'<span>'. hsc($this->label->val()) .'</span>'.DOKU_LF
. $this->mainElementHTML() .DOKU_LF
.'</label>';
return '<label ' . buildAttributes($this->label->attrs()) . '>' . DOKU_LF
. '<span>' . hsc($this->label->val()) . '</span>' . DOKU_LF
. $this->mainElementHTML() . DOKU_LF
. '</label>';
} else {
return $this->mainElementHTML();
}

View File

@ -89,6 +89,6 @@ class TagCloseElement extends ValueElement
*/
public function toHTML()
{
return '</'.$this->val().'>';
return '</' . $this->val() . '>';
}
}

View File

@ -27,6 +27,6 @@ class TagElement extends ValueElement
*/
public function toHTML()
{
return '<'.$this->val().' '.buildAttributes($this->attrs()).' />';
return '<' . $this->val() . ' ' . buildAttributes($this->attrs()) . ' />';
}
}

View File

@ -28,6 +28,6 @@ class TagOpenElement extends ValueElement
*/
public function toHTML()
{
return '<'.$this->val().' '.buildAttributes($this->attrs()).'>';
return '<' . $this->val() . ' ' . buildAttributes($this->attrs()) . '>';
}
}

View File

@ -29,7 +29,7 @@ class Mailer
protected $allowhtml = true;
protected $replacements = ['text'=> [], 'html' => []];
protected $replacements = ['text' => [], 'html' => []];
/**
* Constructor
@ -45,10 +45,10 @@ class Mailer
$server = parse_url(DOKU_URL, PHP_URL_HOST);
if (strpos($server, '.') === false) $server .= '.localhost';
$this->partid = substr(md5(uniqid(random_int(0, mt_getrandmax()), true)), 0, 8).'@'.$server;
$this->boundary = '__________'.md5(uniqid(random_int(0, mt_getrandmax()), true));
$this->partid = substr(md5(uniqid(random_int(0, mt_getrandmax()), true)), 0, 8) . '@' . $server;
$this->boundary = '__________' . md5(uniqid(random_int(0, mt_getrandmax()), true));
$listid = implode('.', array_reverse(explode('/', DOKU_BASE))).$server;
$listid = implode('.', array_reverse(explode('/', DOKU_BASE))) . $server;
$listid = strtolower(trim($listid, '.'));
$messageid = uniqid(random_int(0, mt_getrandmax()), true) . "@$server";
@ -64,7 +64,7 @@ class Mailer
$this->setHeader('X-DokuWiki-Title', $conf['title']);
$this->setHeader('X-DokuWiki-Server', $server);
$this->setHeader('X-Auto-Response-Suppress', 'OOF');
$this->setHeader('List-Id', $conf['title'].' <'.$listid.'>');
$this->setHeader('List-Id', $conf['title'] . ' <' . $listid . '>');
$this->setHeader('Date', date('r'), false);
$this->setHeader('Message-Id', "<$messageid>");
@ -105,7 +105,7 @@ class Mailer
{
if (!$name) {
[, $ext] = explode('/', $mime);
$name = count($this->attach).".$ext";
$name = count($this->attach) . ".$ext";
}
$this->attach[] = [
@ -134,8 +134,8 @@ class Mailer
if (!file_exists($file)) return $matches[0]; //bad reference, keep as is
// attach it and set placeholder
$this->attachFile($file, $mime, '', 'autoembed'.$embeds);
return '%%autoembed'.$embeds.'%%';
$this->attachFile($file, $mime, '', 'autoembed' . $embeds);
return '%%autoembed' . $embeds . '%%';
}
/**
@ -226,7 +226,7 @@ class Mailer
foreach ($textrep as $key => $value) {
if (isset($htmlrep[$key])) continue;
if (media_isexternal($value)) {
$htmlrep[$key] = '<a href="'.hsc($value).'">'.hsc($value).'</a>';
$htmlrep[$key] = '<a href="' . hsc($value) . '">' . hsc($value) . '</a>';
} else {
$htmlrep[$key] = hsc($value);
}
@ -245,10 +245,10 @@ class Mailer
// Apply replacements
foreach ($trep as $key => $substitution) {
$text = str_replace('@'.strtoupper($key).'@', $substitution, $text);
$text = str_replace('@' . strtoupper($key) . '@', $substitution, $text);
}
foreach ($hrep as $key => $substitution) {
$html = str_replace('@'.strtoupper($key).'@', $substitution, $html);
$html = str_replace('@' . strtoupper($key) . '@', $substitution, $html);
}
$this->setHTML($html);
@ -351,7 +351,7 @@ class Mailer
$name = trim($name, " \t\"");
$name = str_replace('"', '\"', $name, $count);
if ($count > 0 || strpos($name, ',') !== false) {
$name = '"'.$name.'"';
$name = '"' . $name . '"';
}
return $name;
}
@ -426,7 +426,7 @@ class Mailer
}
if (strpos($text, ',') !== false || !Clean::isASCII($text)) {
$text = '=?UTF-8?B?'.base64_encode($text).'?=';
$text = '=?UTF-8?B?' . base64_encode($text) . '?=';
}
} else {
$text = '';
@ -436,7 +436,7 @@ class Mailer
if ($headers != '') {
$headers .= ', ';
}
$headers .= $text.' '.$addr;
$headers .= $text . ' ' . $addr;
}
$headers = trim($headers);
@ -462,21 +462,21 @@ class Mailer
$media['name'] = str_replace(':', '_', cleanID($media['name'], true));
// create content id
$cid = 'part'.$part.'.'.$this->partid;
$cid = 'part' . $part . '.' . $this->partid;
// replace wildcards
if ($media['embed']) {
$this->html = str_replace('%%'.$media['embed'].'%%', 'cid:'.$cid, $this->html);
$this->html = str_replace('%%' . $media['embed'] . '%%', 'cid:' . $cid, $this->html);
}
$mime .= '--'.$this->boundary.MAILHEADER_EOL;
$mime .= $this->wrappedHeaderLine('Content-Type', $media['mime'].'; id="'.$cid.'"');
$mime .= '--' . $this->boundary . MAILHEADER_EOL;
$mime .= $this->wrappedHeaderLine('Content-Type', $media['mime'] . '; id="' . $cid . '"');
$mime .= $this->wrappedHeaderLine('Content-Transfer-Encoding', 'base64');
$mime .= $this->wrappedHeaderLine('Content-ID', "<$cid>");
if ($media['embed']) {
$mime .= $this->wrappedHeaderLine('Content-Disposition', 'inline; filename='.$media['name']);
$mime .= $this->wrappedHeaderLine('Content-Disposition', 'inline; filename=' . $media['name']);
} else {
$mime .= $this->wrappedHeaderLine('Content-Disposition', 'attachment; filename='.$media['name']);
$mime .= $this->wrappedHeaderLine('Content-Disposition', 'attachment; filename=' . $media['name']);
}
$mime .= MAILHEADER_EOL; //end of headers
$mime .= chunk_split(base64_encode($media['data']), 74, MAILHEADER_EOL);
@ -516,39 +516,39 @@ class Mailer
$this->headers['Content-Transfer-Encoding'] = 'base64';
$body .= chunk_split(base64_encode($this->text), 72, MAILHEADER_EOL);
} else { // multi part it is
$body .= "This is a multi-part message in MIME format.".MAILHEADER_EOL;
$body .= "This is a multi-part message in MIME format." . MAILHEADER_EOL;
// prepare the attachments
$attachments = $this->prepareAttachments();
// do we have alternative text content?
if ($this->text && $this->html) {
$this->headers['Content-Type'] = 'multipart/alternative;'.MAILHEADER_EOL.
' boundary="'.$this->boundary.'XX"';
$body .= '--'.$this->boundary.'XX'.MAILHEADER_EOL;
$body .= 'Content-Type: text/plain; charset=UTF-8'.MAILHEADER_EOL;
$body .= 'Content-Transfer-Encoding: base64'.MAILHEADER_EOL;
$this->headers['Content-Type'] = 'multipart/alternative;' . MAILHEADER_EOL .
' boundary="' . $this->boundary . 'XX"';
$body .= '--' . $this->boundary . 'XX' . MAILHEADER_EOL;
$body .= 'Content-Type: text/plain; charset=UTF-8' . MAILHEADER_EOL;
$body .= 'Content-Transfer-Encoding: base64' . MAILHEADER_EOL;
$body .= MAILHEADER_EOL;
$body .= chunk_split(base64_encode($this->text), 72, MAILHEADER_EOL);
$body .= '--'.$this->boundary.'XX'.MAILHEADER_EOL;
$body .= 'Content-Type: multipart/related;'.MAILHEADER_EOL.
' boundary="'.$this->boundary.'";'.MAILHEADER_EOL.
' type="text/html"'.MAILHEADER_EOL;
$body .= '--' . $this->boundary . 'XX' . MAILHEADER_EOL;
$body .= 'Content-Type: multipart/related;' . MAILHEADER_EOL .
' boundary="' . $this->boundary . '";' . MAILHEADER_EOL .
' type="text/html"' . MAILHEADER_EOL;
$body .= MAILHEADER_EOL;
}
$body .= '--'.$this->boundary.MAILHEADER_EOL;
$body .= 'Content-Type: text/html; charset=UTF-8'.MAILHEADER_EOL;
$body .= 'Content-Transfer-Encoding: base64'.MAILHEADER_EOL;
$body .= '--' . $this->boundary . MAILHEADER_EOL;
$body .= 'Content-Type: text/html; charset=UTF-8' . MAILHEADER_EOL;
$body .= 'Content-Transfer-Encoding: base64' . MAILHEADER_EOL;
$body .= MAILHEADER_EOL;
$body .= chunk_split(base64_encode($this->html), 72, MAILHEADER_EOL);
$body .= MAILHEADER_EOL;
$body .= $attachments;
$body .= '--'.$this->boundary.'--'.MAILHEADER_EOL;
$body .= '--' . $this->boundary . '--' . MAILHEADER_EOL;
// close open multipart/alternative boundary
if ($this->text && $this->html) {
$body .= '--'.$this->boundary.'XX--'.MAILHEADER_EOL;
$body .= '--' . $this->boundary . 'XX--' . MAILHEADER_EOL;
}
}
@ -575,16 +575,16 @@ class Mailer
// add prefix to subject
if (empty($conf['mailprefix'])) {
if (PhpString::strlen($conf['title']) < 20) {
$prefix = '['.$conf['title'].']';
$prefix = '[' . $conf['title'] . ']';
} else {
$prefix = '['.PhpString::substr($conf['title'], 0, 20).'...]';
$prefix = '[' . PhpString::substr($conf['title'], 0, 20) . '...]';
}
} else {
$prefix = '['.$conf['mailprefix'].']';
$prefix = '[' . $conf['mailprefix'] . ']';
}
$len = strlen($prefix);
if (substr($this->headers['Subject'], 0, $len) !== $prefix) {
$this->headers['Subject'] = $prefix.' '.$this->headers['Subject'];
$this->headers['Subject'] = $prefix . ' ' . $this->headers['Subject'];
}
// encode subject
@ -593,7 +593,7 @@ class Mailer
$this->headers['Subject'] = Clean::strip($this->headers['Subject']);
}
if (!Clean::isASCII($this->headers['Subject'])) {
$this->headers['Subject'] = '=?UTF-8?B?'.base64_encode($this->headers['Subject']).'?=';
$this->headers['Subject'] = '=?UTF-8?B?' . base64_encode($this->headers['Subject']) . '?=';
}
}
@ -608,7 +608,7 @@ class Mailer
*/
protected function wrappedHeaderLine($key, $val)
{
return wordwrap("$key: $val", 78, MAILHEADER_EOL.' ').MAILHEADER_EOL;
return wordwrap("$key: $val", 78, MAILHEADER_EOL . ' ') . MAILHEADER_EOL;
}
/**
@ -641,7 +641,7 @@ class Mailer
if ($body === false) return false;
$headers = $this->prepareHeaders();
return $headers.MAILHEADER_EOL.$body;
return $headers . MAILHEADER_EOL . $body;
}
/**
@ -772,7 +772,7 @@ class Mailer
$headers = $this->prepareHeaders();
// add any headers set by legacy plugins
if (trim($data['headers'])) {
$headers .= MAILHEADER_EOL.trim($data['headers']);
$headers .= MAILHEADER_EOL . trim($data['headers']);
}
if (!function_exists('mail')) {

View File

@ -46,11 +46,11 @@ class Block
foreach ($DOKU_PLUGINS['syntax'] as $n => $p) {
$ptype = $p->getPType();
if ($ptype == 'block') {
$this->blockOpen[] = 'plugin_'.$n;
$this->blockClose[] = 'plugin_'.$n;
$this->blockOpen[] = 'plugin_' . $n;
$this->blockClose[] = 'plugin_' . $n;
} elseif ($ptype == 'stack') {
$this->stackOpen[] = 'plugin_'.$n;
$this->stackClose[] = 'plugin_'.$n;
$this->stackOpen[] = 'plugin_' . $n;
$this->stackClose[] = 'plugin_' . $n;
}
}
}
@ -78,7 +78,7 @@ class Block
// look back if there was any content - we don't want empty paragraphs
$content = '';
$ccount = count($this->calls);
for ($i=$ccount-1; $i>=0; $i--) {
for ($i = $ccount - 1; $i >= 0; $i--) {
if ($this->calls[$i][0] == 'p_open') {
break;
} elseif ($this->calls[$i][0] == 'cdata') {
@ -89,16 +89,16 @@ class Block
}
}
if (trim($content)=='') {
if (trim($content) == '') {
//remove the whole paragraph
//array_splice($this->calls,$i); // <- this is much slower than the loop below
for (
$x=$ccount; $x>$i;
$x = $ccount; $x > $i;
$x--
) array_pop($this->calls);
} else {
// remove ending linebreaks in the paragraph
$i=count($this->calls)-1;
$i = count($this->calls) - 1;
if ($this->calls[$i][0] == 'cdata') $this->calls[$i][1][0] = rtrim($this->calls[$i][1][0], "\n");
$this->calls[] = ['p_close', [], $pos];
}
@ -110,8 +110,8 @@ class Block
protected function addCall($call)
{
$key = count($this->calls);
if ($key && $call[0] == 'cdata' && $this->calls[$key-1][0] == 'cdata') {
$this->calls[$key-1][1][0] .= $call[1][0];
if ($key && $call[0] == 'cdata' && $this->calls[$key - 1][0] == 'cdata') {
$this->calls[$key - 1][1][0] .= $call[1][0];
} else {
$this->calls[] = $call;
}
@ -140,7 +140,7 @@ class Block
foreach ($calls as $key => $call) {
$cname = $call[0];
if ($cname == 'plugin') {
$cname='plugin_'.$call[1][0];
$cname = 'plugin_' . $call[1][0];
$plugin = true;
$plugin_open = (($call[1][2] == DOKU_LEXER_ENTER) || ($call[1][2] == DOKU_LEXER_SPECIAL));
$plugin_close = (($call[1][2] == DOKU_LEXER_EXIT) || ($call[1][2] == DOKU_LEXER_SPECIAL));
@ -179,7 +179,7 @@ class Block
// Check this isn't an eol instruction to skip...
if (!$this->skipEol) {
// Next is EOL => double eol => mark as paragraph
if (isset($calls[$key+1]) && $calls[$key+1][0] == 'eol') {
if (isset($calls[$key + 1]) && $calls[$key + 1][0] == 'eol') {
$this->closeParagraph($call[2]);
$this->openParagraph($call[2]);
} else {

View File

@ -55,7 +55,7 @@ class Lists extends AbstractRewriter
// array(list type, current depth, index of current listitem_open)
$this->listStack[] = [$listType, $depth, 1];
$this->listCalls[] = ['list'.$listType.'_open', [], $call[2]];
$this->listCalls[] = ['list' . $listType . '_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
}
@ -71,7 +71,7 @@ class Lists extends AbstractRewriter
$closeContent = false;
}
$this->listCalls[] = ['listitem_close', [], $call[2]];
$this->listCalls[] = ['list'.$list[0].'_close', [], $call[2]];
$this->listCalls[] = ['list' . $list[0] . '_close', [], $call[2]];
}
}
@ -91,7 +91,7 @@ class Lists extends AbstractRewriter
if ($listType == $end[0]) {
$this->listCalls[] = ['listcontent_close', [], $call[2]];
$this->listCalls[] = ['listitem_close', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth-1], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth - 1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
// new list item, update list stack's index into current listitem_open
@ -101,9 +101,9 @@ class Lists extends AbstractRewriter
} else {
$this->listCalls[] = ['listcontent_close', [], $call[2]];
$this->listCalls[] = ['listitem_close', [], $call[2]];
$this->listCalls[] = ['list'.$end[0].'_close', [], $call[2]];
$this->listCalls[] = ['list'.$listType.'_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth-1], $call[2]];
$this->listCalls[] = ['list' . $end[0] . '_close', [], $call[2]];
$this->listCalls[] = ['list' . $listType . '_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth - 1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
array_pop($this->listStack);
@ -111,8 +111,8 @@ class Lists extends AbstractRewriter
}
} elseif ($depth > $end[1]) { // Getting deeper...
$this->listCalls[] = ['listcontent_close', [], $call[2]];
$this->listCalls[] = ['list'.$listType.'_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth-1], $call[2]];
$this->listCalls[] = ['list' . $listType . '_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth - 1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
// set the node/leaf state of this item's parent listitem_open to NODE
@ -122,7 +122,7 @@ class Lists extends AbstractRewriter
} else { // Getting shallower ( $depth < $end[1] )
$this->listCalls[] = ['listcontent_close', [], $call[2]];
$this->listCalls[] = ['listitem_close', [], $call[2]];
$this->listCalls[] = ['list'.$end[0].'_close', [], $call[2]];
$this->listCalls[] = ['list' . $end[0] . '_close', [], $call[2]];
// Throw away the end - done
array_pop($this->listStack);
@ -138,16 +138,16 @@ class Lists extends AbstractRewriter
$this->listCalls[] = ['listitem_close', [], $call[2]];
if ($end[0] == $listType) {
$this->listCalls[] = ['listitem_open', [$depth-1], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth - 1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
// new list item, update list stack's index into current listitem_open
$this->listStack[$key][2] = count($this->listCalls) - 2;
} else {
// Switching list type...
$this->listCalls[] = ['list'.$end[0].'_close', [], $call[2]];
$this->listCalls[] = ['list'.$listType.'_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth-1], $call[2]];
$this->listCalls[] = ['list' . $end[0] . '_close', [], $call[2]];
$this->listCalls[] = ['list' . $listType . '_open', [], $call[2]];
$this->listCalls[] = ['listitem_open', [$depth - 1], $call[2]];
$this->listCalls[] = ['listcontent_open', [], $call[2]];
array_pop($this->listStack);
@ -159,7 +159,7 @@ class Lists extends AbstractRewriter
// Haven't dropped down far enough yet.... ( $end[1] > $depth )
} else {
$this->listCalls[] = ['listitem_close', [], $call[2]];
$this->listCalls[] = ['list'.$end[0].'_close', [], $call[2]];
$this->listCalls[] = ['list' . $end[0] . '_close', [], $call[2]];
array_pop($this->listStack);
}

View File

@ -69,8 +69,8 @@ class Nest extends AbstractRewriter
protected function addCall($call)
{
$key = count($this->calls);
if ($key && $call[0] == 'cdata' && $this->calls[$key-1][0] == 'cdata') {
$this->calls[$key-1][1][0] .= $call[1][0];
if ($key && $call[0] == 'cdata' && $this->calls[$key - 1][0] == 'cdata') {
$this->calls[$key - 1][1][0] .= $call[1][0];
} elseif ($call[0] == 'eol') {
// do nothing (eol shouldn't be allowed, to counter preformatted fix in #1652 & #1699)
} else {

View File

@ -6,7 +6,7 @@ class Preformatted extends AbstractRewriter
{
protected $pos;
protected $text ='';
protected $text = '';
/** @inheritdoc */
public function finalise()

View File

@ -108,7 +108,7 @@ class Table extends AbstractRewriter
$th = $this->currentRow['tableheader'];
if (!$th || $td > 2) return false;
if (2*$td > $th) return false;
if (2 * $td > $th) return false;
return true;
}
@ -127,11 +127,11 @@ class Table extends AbstractRewriter
$this->tableCalls[] = ['colspan', [], $call[2]];
}
$this->tableCalls[] = [$this->lastCellType.'_close', [], $call[2]];
$this->tableCalls[] = [$call[0].'_open', [1, null, 1], $call[2]];
$this->tableCalls[] = [$this->lastCellType . '_close', [], $call[2]];
$this->tableCalls[] = [$call[0] . '_open', [1, null, 1], $call[2]];
$this->lastCellType = $call[0];
} else {
$this->tableCalls[] = [$call[0].'_open', [1, null, 1], $call[2]];
$this->tableCalls[] = [$call[0] . '_open', [1, null, 1], $call[2]];
$this->lastCellType = $call[0];
$this->firstCell = false;
}
@ -182,7 +182,7 @@ class Table extends AbstractRewriter
switch ($call[0]) {
case 'table_open':
if ($this->countTableHeadRows) {
array_splice($this->tableCalls, $key+1, 0, [['tablethead_open', [], $call[2]]]);
array_splice($this->tableCalls, $key + 1, 0, [['tablethead_open', [], $call[2]]]);
}
break;
@ -198,15 +198,15 @@ class Table extends AbstractRewriter
break;
case 'table_align':
$prev = in_array($this->tableCalls[$key-1][0], ['tablecell_open', 'tableheader_open']);
$next = in_array($this->tableCalls[$key+1][0], ['tablecell_close', 'tableheader_close']);
$prev = in_array($this->tableCalls[$key - 1][0], ['tablecell_open', 'tableheader_open']);
$next = in_array($this->tableCalls[$key + 1][0], ['tablecell_close', 'tableheader_close']);
// If the cell is empty, align left
if ($prev && $next) {
$this->tableCalls[$key-1][1][1] = 'left';
$this->tableCalls[$key - 1][1][1] = 'left';
// If the previous element was a cell open, align right
} elseif ($prev) {
$this->tableCalls[$key-1][1][1] = 'right';
$this->tableCalls[$key - 1][1][1] = 'right';
// If the next element is the close of an element, align either center or left
} elseif ($next) {
@ -222,9 +222,9 @@ class Table extends AbstractRewriter
break;
case 'colspan':
$this->tableCalls[$key-1][1][0] = false;
$this->tableCalls[$key - 1][1][0] = false;
for ($i = $key-2; $i >= $cellKey[$lastRow][1]; $i--) {
for ($i = $key - 2; $i >= $cellKey[$lastRow][1]; $i--) {
if (
$this->tableCalls[$i][0] == 'tablecell_open' ||
$this->tableCalls[$i][0] == 'tableheader_open'
@ -236,13 +236,13 @@ class Table extends AbstractRewriter
}
}
$toDelete[] = $key-1;
$toDelete[] = $key - 1;
$toDelete[] = $key;
$toDelete[] = $key+1;
$toDelete[] = $key + 1;
break;
case 'rowspan':
if ($this->tableCalls[$key-1][0] == 'cdata') {
if ($this->tableCalls[$key - 1][0] == 'cdata') {
// ignore rowspan if previous call was cdata (text mixed with :::)
// we don't have to check next call as that wont match regex
$this->tableCalls[$key][0] = 'cdata';
@ -250,8 +250,8 @@ class Table extends AbstractRewriter
$spanning_cell = null;
// can't cross thead/tbody boundary
if (!$this->countTableHeadRows || ($lastRow-1 != $this->countTableHeadRows)) {
for ($i = $lastRow-1; $i > 0; $i--) {
if (!$this->countTableHeadRows || ($lastRow - 1 != $this->countTableHeadRows)) {
for ($i = $lastRow - 1; $i > 0; $i--) {
if (
$this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' ||
$this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open'
@ -272,11 +272,11 @@ class Table extends AbstractRewriter
}
$this->tableCalls[$cellKey[$spanning_cell][$lastCell]][1][2]++;
$this->tableCalls[$key-1][1][2] = false;
$this->tableCalls[$key - 1][1][2] = false;
$toDelete[] = $key-1;
$toDelete[] = $key - 1;
$toDelete[] = $key;
$toDelete[] = $key+1;
$toDelete[] = $key + 1;
}
break;
@ -295,7 +295,7 @@ class Table extends AbstractRewriter
}
if ($this->countTableHeadRows == $lastRow) {
array_splice($this->tableCalls, $key+1, 0, [['tablethead_close', [], $call[2]]]);
array_splice($this->tableCalls, $key + 1, 0, [['tablethead_close', [], $call[2]]]);
}
break;
}

View File

@ -263,7 +263,7 @@ class Lexer
// modes starting with plugin_ are all handled by the same
// handler but with an additional parameter
if (substr($handler, 0, 7)=='plugin_') {
if (substr($handler, 0, 7) == 'plugin_') {
[$handler, $plugin] = sexplode('_', $handler, 2, '');
return $this->handler->$handler($content, $is_match, $pos, $plugin);
}

View File

@ -122,8 +122,8 @@ class ParallelRegex
return false;
}
$idx = count($matches)-2;
[$pre, $post] = preg_split($this->patterns[$idx].$this->getPerlMatchingFlags(), $subject, 2);
$idx = count($matches) - 2;
[$pre, $post] = preg_split($this->patterns[$idx] . $this->getPerlMatchingFlags(), $subject, 2);
$split = [$pre, $matches[0], $post];
return $this->labels[$idx] ?? true;

View File

@ -26,7 +26,7 @@ class Acronym extends AbstractMode
$bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]';
$acronyms = array_map(['\\dokuwiki\\Parsing\\Lexer\\Lexer', 'escape'], $this->acronyms);
$this->pattern = '(?<=^|'.$bound.')(?:'.implode('|', $acronyms).')(?='.$bound.')';
$this->pattern = '(?<=^|' . $bound . ')(?:' . implode('|', $acronyms) . ')(?=' . $bound . ')';
}
/** @inheritdoc */

View File

@ -9,7 +9,7 @@ class Emaillink extends AbstractMode
public function connectTo($mode)
{
// pattern below is defined in inc/mail.php
$this->Lexer->addSpecialPattern('<'.PREG_PATTERN_VALID_EMAIL.'>', $mode, 'emaillink');
$this->Lexer->addSpecialPattern('<' . PREG_PATTERN_VALID_EMAIL . '>', $mode, 'emaillink');
}
/** @inheritdoc */

View File

@ -27,7 +27,7 @@ class Entity extends AbstractMode
$sep = '';
foreach ($this->entities as $entity) {
$this->pattern .= $sep. Lexer::escape($entity);
$this->pattern .= $sep . Lexer::escape($entity);
$sep = '|';
}
}

View File

@ -15,18 +15,18 @@ class Externallink extends AbstractMode
$ltrs = '\w';
$gunk = '/\#~:.?+=&%@!\-\[\]';
$punc = '.:?\-;,';
$host = $ltrs.$punc;
$any = $ltrs.$gunk.$punc;
$host = $ltrs . $punc;
$any = $ltrs . $gunk . $punc;
$this->schemes = getSchemes();
foreach ($this->schemes as $scheme) {
$this->patterns[] = '\b(?i)'.$scheme.'(?-i)://['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '\b(?i)' . $scheme . '(?-i)://[' . $any . ']+?(?=[' . $punc . ']*[^' . $any . '])';
}
$this->patterns[] = '(?<![/\\\\])\b(?i)www?(?-i)\.['.$host.']+?\.'.
'['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '(?<![/\\\\])\b(?i)ftp?(?-i)\.['.$host.']+?\.'.
'['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])';
$this->patterns[] = '(?<![/\\\\])\b(?i)www?(?-i)\.[' . $host . ']+?\.' .
'[' . $host . ']+?[' . $any . ']+?(?=[' . $punc . ']*[^' . $any . '])';
$this->patterns[] = '(?<![/\\\\])\b(?i)ftp?(?-i)\.[' . $host . ']+?\.' .
'[' . $host . ']+?[' . $any . ']+?(?=[' . $punc . ']*[^' . $any . '])';
}
/** @inheritdoc */

View File

@ -14,10 +14,10 @@ class Filelink extends AbstractMode
$ltrs = '\w';
$gunk = '/\#~:.?+=&%@!\-';
$punc = '.:?\-;,';
$any = $ltrs.$gunk.$punc;
$any = $ltrs . $gunk . $punc;
$this->pattern = '\b(?i)file(?-i)://['.$any.']+?['.
$punc.']*[^'.$any.']';
$this->pattern = '\b(?i)file(?-i)://[' . $any . ']+?[' .
$punc . ']*[^' . $any . ']';
}
/** @inheritdoc */

View File

@ -25,7 +25,7 @@ class Smiley extends AbstractMode
$sep = '';
foreach ($this->smileys as $smiley) {
$this->pattern .= $sep.'(?<=\W|^)'. Lexer::escape($smiley).'(?=\W|$)';
$this->pattern .= $sep . '(?<=\W|^)' . Lexer::escape($smiley) . '(?=\W|$)';
$sep = '|';
}
}

View File

@ -31,7 +31,7 @@ class Wordblock extends AbstractMode
$sep = '';
foreach ($this->badwords as $badword) {
$this->pattern .= $sep.'(?<=\b)(?i)'. Lexer::escape($badword).'(?-i)(?=\b)';
$this->pattern .= $sep . '(?<=\b)(?i)' . Lexer::escape($badword) . '(?-i)(?=\b)';
$sep = '|';
}
}

View File

@ -93,8 +93,8 @@ class PassHash
$salt = $m[3];
$magic = ['prefix' => $m[1], 'rounds' => $m[2]];
} elseif (preg_match('/^\$(argon2id?)/', $hash, $m)) {
if (!defined('PASSWORD_'.strtoupper($m[1]))) {
throw new \Exception('This PHP installation has no '.strtoupper($m[1]).' support');
if (!defined('PASSWORD_' . strtoupper($m[1]))) {
throw new \Exception('This PHP installation has no ' . strtoupper($m[1]) . ' support');
}
return password_verify($clear, $hash);
} elseif ($len == 32) {
@ -114,7 +114,7 @@ class PassHash
}
//crypt and compare
$call = 'hash_'.$method;
$call = 'hash_' . $method;
$newhash = $this->$call($clear, $salt, $magic);
if (\hash_equals($newhash, $hash)) {
return true;
@ -181,7 +181,7 @@ class PassHash
$this->init_salt($salt, 8);
if (defined('CRYPT_MD5') && CRYPT_MD5 && $salt !== '') {
return crypt($clear, '$1$'.$salt.'$');
return crypt($clear, '$1$' . $salt . '$');
} else {
// Fall back to PHP-only implementation
return $this->hash_apr1($clear, $salt, '1');
@ -202,7 +202,7 @@ class PassHash
public function hash_lsmd5($clear, $salt = null)
{
$this->init_salt($salt, 8);
return "{SMD5}".base64_encode(md5($clear.$salt, true).$salt);
return "{SMD5}" . base64_encode(md5($clear . $salt, true) . $salt);
}
/**
@ -225,8 +225,8 @@ class PassHash
$this->init_salt($salt, 8);
$len = strlen($clear);
$text = $clear.'$'.$magic.'$'.$salt;
$bin = pack("H32", md5($clear.$salt.$clear));
$text = $clear . '$' . $magic . '$' . $salt;
$bin = pack("H32", md5($clear . $salt . $clear));
for ($i = $len; $i > 0; $i -= 16) {
$text .= substr($bin, 0, min(16, $i));
}
@ -246,15 +246,15 @@ class PassHash
$k = $i + 6;
$j = $i + 12;
if ($j == 16) $j = 5;
$tmp = $bin[$i].$bin[$k].$bin[$j].$tmp;
$tmp = $bin[$i] . $bin[$k] . $bin[$j] . $tmp;
}
$tmp = chr(0).chr(0).$bin[11].$tmp;
$tmp = chr(0) . chr(0) . $bin[11] . $tmp;
$tmp = strtr(
strrev(substr(base64_encode($tmp), 2)),
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
);
return '$'.$magic.'$'.$salt.'$'.$tmp;
return '$' . $magic . '$' . $salt . '$' . $tmp;
}
/**
@ -295,7 +295,7 @@ class PassHash
public function hash_ssha($clear, $salt = null)
{
$this->init_salt($salt, 4);
return '{SSHA}'.base64_encode(pack("H*", sha1($clear.$salt)).$salt);
return '{SSHA}' . base64_encode(pack("H*", sha1($clear . $salt)) . $salt);
}
/**
@ -349,7 +349,7 @@ class PassHash
*/
public function hash_my411($clear)
{
return '*'.strtoupper(sha1(pack("H*", sha1($clear))));
return '*' . strtoupper(sha1(pack("H*", sha1($clear))));
}
/**
@ -369,8 +369,8 @@ class PassHash
$this->init_salt($salt);
$key = substr($salt, 16, 2);
$hash1 = strtolower(md5($key.md5($clear)));
$hash2 = substr($hash1, 0, 16).$key.substr($hash1, 16);
$hash1 = strtolower(md5($key . md5($clear)));
$hash2 = substr($hash1, 0, 16) . $key . substr($hash1, 16);
return $hash2;
}
@ -405,14 +405,14 @@ class PassHash
$itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_null($salt)) {
$this->init_salt($salt);
$salt = $itoa64[$compute].$salt; // prefix iteration count
$salt = $itoa64[$compute] . $salt; // prefix iteration count
}
$iterc = $salt[0]; // pos 0 of salt is log2(iteration count)
$iter = strpos($itoa64, $iterc);
if ($iter > 30) {
throw new \Exception("Too high iteration count ($iter) in ".
self::class.'::'.__FUNCTION__);
throw new \Exception("Too high iteration count ($iter) in " .
self::class . '::' . __FUNCTION__);
}
$iter = 1 << $iter;
@ -421,7 +421,7 @@ class PassHash
// iterate
$hash = hash($algo, $salt . $clear, true);
do {
$hash = hash($algo, $hash.$clear, true);
$hash = hash($algo, $hash . $clear, true);
} while (--$iter);
// encode
@ -444,7 +444,7 @@ class PassHash
$output .= $itoa64[($value >> 18) & 0x3f];
} while ($i < $count);
return '$'.$magic.'$'.$iterc.$salt.$output;
return '$' . $magic . '$' . $iterc . $salt . $output;
}
/**
@ -523,7 +523,7 @@ class PassHash
public function hash_djangosha1($clear, $salt = null)
{
$this->init_salt($salt, 5);
return 'sha1$'.$salt.'$'.sha1($salt.$clear);
return 'sha1$' . $salt . '$' . sha1($salt . $clear);
}
/**
@ -541,7 +541,7 @@ class PassHash
public function hash_djangomd5($clear, $salt = null)
{
$this->init_salt($salt, 5);
return 'md5$'.$salt.'$'.md5($salt.$clear);
return 'md5$' . $salt . '$' . md5($salt . $clear);
}
/**
@ -565,9 +565,9 @@ class PassHash
{
$this->init_salt($salt, 64);
if (empty($opts['algo'])) {
$prefixalgo='SHA256';
$prefixalgo = 'SHA256';
} else {
$prefixalgo=$opts['algo'];
$prefixalgo = $opts['algo'];
}
$algo = strtolower($prefixalgo);
if (empty($opts['iter'])) {
@ -677,7 +677,7 @@ class PassHash
if (is_null($salt)) {
if ($compute < 4 || $compute > 31) $compute = 8;
$salt = '$2y$'.str_pad($compute, 2, '0', STR_PAD_LEFT).'$'.
$salt = '$2y$' . str_pad($compute, 2, '0', STR_PAD_LEFT) . '$' .
$this->gen_salt(22);
}
@ -720,9 +720,9 @@ class PassHash
}
$this->init_salt($salt, 8, false);
if (empty($rounds)) {
return crypt($clear, '$'.$prefix.'$'.$salt.'$');
return crypt($clear, '$' . $prefix . '$' . $salt . '$');
} else {
return crypt($clear, '$'.$prefix.'$'.$rounds.'$'.$salt.'$');
return crypt($clear, '$' . $prefix . '$' . $rounds . '$' . $salt . '$');
}
}
@ -755,7 +755,7 @@ class PassHash
public function hash_mediawiki($clear, $salt = null)
{
$this->init_salt($salt, 8, false);
return ':B:'.$salt.':'.md5($salt.'-'.md5($clear));
return ':B:' . $salt . ':' . md5($salt . '-' . md5($clear));
}

View File

@ -88,7 +88,7 @@ class SafeFN
public static function validateSafe($safe)
{
return !preg_match('#[^'.self::$plain.self::$post_indicator.self::$pre_indicator.']#', $safe);
return !preg_match('#[^' . self::$plain . self::$post_indicator . self::$pre_indicator . ']#', $safe);
}
/**
@ -106,7 +106,7 @@ class SafeFN
$converted = false;
foreach ($unicode as $codepoint) {
if ($codepoint < 127 && (strpos(self::$plain.self::$post_indicator, chr($codepoint))!==false)) {
if ($codepoint < 127 && (strpos(self::$plain . self::$post_indicator, chr($codepoint)) !== false)) {
if ($converted) {
$safe .= self::$post_indicator;
$converted = false;
@ -116,7 +116,7 @@ class SafeFN
$safe .= self::$pre_indicator;
$converted = true;
} else {
$safe .= self::$pre_indicator.base_convert((string)($codepoint-32), 10, 36);
$safe .= self::$pre_indicator . base_convert((string)($codepoint - 32), 10, 36);
$converted = true;
}
}
@ -136,7 +136,12 @@ class SafeFN
{
$unicode = [];
$split = preg_split('#(?=['.self::$post_indicator.self::$pre_indicator.'])#', $safe, -1, PREG_SPLIT_NO_EMPTY);
$split = preg_split(
'#(?=[' . self::$post_indicator . self::$pre_indicator . '])#',
$safe,
-1,
PREG_SPLIT_NO_EMPTY
);
$converted = false;
foreach ($split as $sub) {
@ -144,11 +149,11 @@ class SafeFN
if ($sub[0] != self::$pre_indicator) {
// plain (unconverted) characters, optionally starting with a post_indicator
// set initial value to skip any post_indicator
for ($i=($converted?1:0); $i < $len; $i++) {
for ($i = ($converted ? 1 : 0); $i < $len; $i++) {
$unicode[] = ord($sub[$i]);
}
$converted = false;
} elseif ($len==1) {
} elseif ($len == 1) {
// a pre_indicator character in the real data
$unicode[] = ord($sub);
$converted = true;

View File

@ -56,7 +56,7 @@ class Indexer
foreach (array_keys($words) as $wlen) {
$index = $this->getIndex('i', $wlen);
foreach ($words[$wlen] as $wid => $freq) {
$idx = ($wid<count($index)) ? $index[$wid] : '';
$idx = ($wid < count($index)) ? $index[$wid] : '';
$index[$wid] = $this->updateTuple($idx, $pid, $freq);
$pagewords[] = "$wlen*$wid";
}
@ -198,13 +198,13 @@ class Indexer
foreach ($key as $name => $values) {
$metaname = idx_cleanName($name);
$this->addIndexKey('metadata', '', $metaname);
$metaidx = $this->getIndex($metaname.'_i', '');
$metawords = $this->getIndex($metaname.'_w', '');
$metaidx = $this->getIndex($metaname . '_i', '');
$metawords = $this->getIndex($metaname . '_w', '');
$addwords = false;
if (!is_array($values)) $values = [$values];
$val_idx = $this->getIndexKey($metaname.'_p', '', $pid);
$val_idx = $this->getIndexKey($metaname . '_p', '', $pid);
if ($val_idx !== '') {
$val_idx = explode(':', $val_idx);
// -1 means remove, 0 keep, 1 add
@ -234,7 +234,7 @@ class Indexer
}
if ($addwords) {
$this->saveIndex($metaname.'_w', '', $metawords);
$this->saveIndex($metaname . '_w', '', $metawords);
}
$vals_changed = false;
foreach ($val_idx as $id => $action) {
@ -249,9 +249,9 @@ class Indexer
}
if ($vals_changed) {
$this->saveIndex($metaname.'_i', '', $metaidx);
$this->saveIndex($metaname . '_i', '', $metaidx);
$val_idx = implode(':', array_keys($val_idx));
$this->saveIndexKey($metaname.'_p', '', $pid, $val_idx);
$this->saveIndexKey($metaname . '_p', '', $pid, $val_idx);
}
unset($metaidx);
@ -290,7 +290,7 @@ class Indexer
return false;
}
$pages[$new_id] = 'deleted:'.time().random_int(0, 9999);
$pages[$new_id] = 'deleted:' . time() . random_int(0, 9999);
}
$pages[$id] = $newpage;
@ -331,10 +331,10 @@ class Indexer
unset($metavalues);
// okay, now we have two entries for the same value. we need to merge them.
$indexline = $this->getIndexKey($key.'_i', '', $oldid);
$indexline = $this->getIndexKey($key . '_i', '', $oldid);
if ($indexline != '') {
$newindexline = $this->getIndexKey($key.'_i', '', $newid);
$pagekeys = $this->getIndex($key.'_p', '');
$newindexline = $this->getIndexKey($key . '_i', '', $newid);
$pagekeys = $this->getIndex($key . '_p', '');
$parts = explode(':', $indexline);
foreach ($parts as $part) {
[$id, $count] = explode('*', $part);
@ -349,14 +349,14 @@ class Indexer
}
$pagekeys[$id] = implode(':', $keyline);
}
$this->saveIndex($key.'_p', '', $pagekeys);
$this->saveIndex($key . '_p', '', $pagekeys);
unset($pagekeys);
$this->saveIndexKey($key.'_i', '', $oldid, '');
$this->saveIndexKey($key.'_i', '', $newid, $newindexline);
$this->saveIndexKey($key . '_i', '', $oldid, '');
$this->saveIndexKey($key . '_i', '', $newid, $newindexline);
}
} else {
$metavalues[$oldid] = $newvalue;
if (!$this->saveIndex($key.'_w', '', $metavalues)) {
if (!$this->saveIndex($key . '_w', '', $metavalues)) {
$this->unlock();
return false;
}
@ -435,14 +435,14 @@ class Indexer
$this->saveIndexKey('title', '', $pid, "");
$keyidx = $this->getIndex('metadata', '');
foreach ($keyidx as $metaname) {
$val_idx = explode(':', $this->getIndexKey($metaname.'_p', '', $pid));
$meta_idx = $this->getIndex($metaname.'_i', '');
$val_idx = explode(':', $this->getIndexKey($metaname . '_p', '', $pid));
$meta_idx = $this->getIndex($metaname . '_i', '');
foreach ($val_idx as $id) {
if ($id === '') continue;
$meta_idx[$id] = $this->updateTuple($meta_idx[$id], $pid, 0);
}
$this->saveIndex($metaname.'_i', '', $meta_idx);
$this->saveIndexKey($metaname.'_p', '', $pid, '');
$this->saveIndex($metaname . '_i', '', $meta_idx);
$this->saveIndexKey($metaname . '_p', '', $pid, '');
}
return true;
@ -459,25 +459,25 @@ class Indexer
if (!$this->lock()) return false;
@unlink($conf['indexdir'].'/page.idx');
@unlink($conf['indexdir'].'/title.idx');
@unlink($conf['indexdir'].'/pageword.idx');
@unlink($conf['indexdir'].'/metadata.idx');
@unlink($conf['indexdir'] . '/page.idx');
@unlink($conf['indexdir'] . '/title.idx');
@unlink($conf['indexdir'] . '/pageword.idx');
@unlink($conf['indexdir'] . '/metadata.idx');
$dir = @opendir($conf['indexdir']);
if ($dir!==false) {
if ($dir !== false) {
while (($f = readdir($dir)) !== false) {
if (
substr($f, -4)=='.idx' &&
(substr($f, 0, 1)=='i' ||
substr($f, 0, 1)=='w' ||
substr($f, -6)=='_w.idx' ||
substr($f, -6)=='_i.idx' ||
substr($f, -6)=='_p.idx')
substr($f, -4) == '.idx' &&
(substr($f, 0, 1) == 'i' ||
substr($f, 0, 1) == 'w' ||
substr($f, -6) == '_w.idx' ||
substr($f, -6) == '_i.idx' ||
substr($f, -6) == '_p.idx')
)
@unlink($conf['indexdir']."/$f");
@unlink($conf['indexdir'] . "/$f");
}
}
@unlink($conf['indexdir'].'/lengths.idx');
@unlink($conf['indexdir'] . '/lengths.idx');
// clear the pid cache
$this->pidCache = [];
@ -522,7 +522,7 @@ class Indexer
["\r" => ' ', "\n" => ' ', "\t" => ' ', "\xC2\xAD" => '']
);
if (preg_match('/[^0-9A-Za-z ]/u', $text))
$text = Clean::stripspecials($text, ' ', '\._\-:'.$wc);
$text = Clean::stripspecials($text, ' ', '\._\-:' . $wc);
$wordlist = explode(' ', $text);
foreach ($wordlist as $i => $word) {
@ -681,7 +681,7 @@ class Indexer
if ($key == 'title') {
$words = $this->getIndex('title', '');
} else {
$words = $this->getIndex($metaname.'_w', '');
$words = $this->getIndex($metaname . '_w', '');
}
if (!is_null($func)) {
@ -706,8 +706,8 @@ class Indexer
$dollar = '';
}
if (!$caret || !$dollar) {
$re = $caret.preg_quote($xval, '/').$dollar;
foreach (array_keys(preg_grep('/'.$re.'/', $words)) as $i)
$re = $caret . preg_quote($xval, '/') . $dollar;
foreach (array_keys(preg_grep('/' . $re . '/', $words)) as $i)
$value_ids[$i][] = $val;
} elseif (($i = array_search($val, $words, true)) !== false) {
$value_ids[$i][] = $val;
@ -735,7 +735,7 @@ class Indexer
}
} else {
// load all lines and pages so the used lines can be taken and matched with the pages
$lines = $this->getIndex($metaname.'_i', '');
$lines = $this->getIndex($metaname . '_i', '');
foreach ($value_ids as $value_id => $val_list) {
// parse the tuples of the form page_id*1:page2_id*1 and so on, return value
@ -792,8 +792,8 @@ class Indexer
if (!isset($tokens[$xword]))
$tokenlength[$wlen][] = $xword;
if (!$caret || !$dollar) {
$re = $caret.preg_quote($xword, '/').$dollar;
$tokens[$xword][] = [$word, '/'.$re.'/'];
$re = $caret . preg_quote($xword, '/') . $dollar;
$tokens[$xword][] = [$word, '/' . $re . '/'];
if (!isset($tokenwild[$xword]))
$tokenwild[$xword] = $wlen;
} else {
@ -863,7 +863,7 @@ class Indexer
}
$pages = [];
$lines = $this->getIndex($metaname.'_i', '');
$lines = $this->getIndex($metaname . '_i', '');
foreach ($lines as $line) {
$pages = array_merge($pages, $this->parseTuples($page_idx, $line));
}
@ -899,7 +899,7 @@ class Indexer
}
} elseif (!is_null($key)) {
$metaname = idx_cleanName($key);
$index = $this->getIndex($metaname.'_i', '');
$index = $this->getIndex($metaname . '_i', '');
$val_idx = [];
foreach ($index as $wid => $line) {
$freq = $this->countTuples($line);
@ -907,7 +907,7 @@ class Indexer
$val_idx[$wid] = $freq;
}
if (!empty($val_idx)) {
$words = $this->getIndex($metaname.'_w', '');
$words = $this->getIndex($metaname . '_w', '');
foreach ($val_idx as $wid => $freq) {
if (strlen($words[$wid]) >= $minlen)
$result[$words[$wid]] = $freq;
@ -946,10 +946,10 @@ class Indexer
global $conf;
$status = true;
$run = 0;
$lock = $conf['lockdir'].'/_indexer.lock';
$lock = $conf['lockdir'] . '/_indexer.lock';
while (!@mkdir($lock)) {
usleep(50);
if (is_dir($lock) && time()-@filemtime($lock) > 60*5) {
if (is_dir($lock) && time() - @filemtime($lock) > 60 * 5) {
// looks like a stale lock - remove it
if (!@rmdir($lock)) {
$status = "removing the stale lock failed";
@ -978,7 +978,7 @@ class Indexer
protected function unlock()
{
global $conf;
@rmdir($conf['lockdir'].'/_indexer.lock');
@rmdir($conf['lockdir'] . '/_indexer.lock');
return true;
}
@ -998,7 +998,7 @@ class Indexer
protected function getIndex($idx, $suffix)
{
global $conf;
$fn = $conf['indexdir'].'/'.$idx.$suffix.'.idx';
$fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx';
if (!file_exists($fn)) return [];
return file($fn, FILE_IGNORE_NEW_LINES);
}
@ -1016,16 +1016,16 @@ class Indexer
protected function saveIndex($idx, $suffix, &$lines)
{
global $conf;
$fn = $conf['indexdir'].'/'.$idx.$suffix;
$fh = @fopen($fn.'.tmp', 'w');
$fn = $conf['indexdir'] . '/' . $idx . $suffix;
$fh = @fopen($fn . '.tmp', 'w');
if (!$fh) return false;
fwrite($fh, implode("\n", $lines));
if (!empty($lines))
fwrite($fh, "\n");
fclose($fh);
if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
chmod($fn . '.tmp', $conf['fperm']);
io_rename($fn . '.tmp', $fn . '.idx');
return true;
}
@ -1042,7 +1042,7 @@ class Indexer
protected function getIndexKey($idx, $suffix, $id)
{
global $conf;
$fn = $conf['indexdir'].'/'.$idx.$suffix.'.idx';
$fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx';
if (!file_exists($fn)) return '';
$fh = @fopen($fn, 'r');
if (!$fh) return '';
@ -1070,10 +1070,10 @@ class Indexer
global $conf;
if (substr($line, -1) != "\n")
$line .= "\n";
$fn = $conf['indexdir'].'/'.$idx.$suffix;
$fh = @fopen($fn.'.tmp', 'w');
$fn = $conf['indexdir'] . '/' . $idx . $suffix;
$fh = @fopen($fn . '.tmp', 'w');
if (!$fh) return false;
$ih = @fopen($fn.'.idx', 'r');
$ih = @fopen($fn . '.idx', 'r');
if ($ih) {
$ln = -1;
while (($curline = fgets($ih)) !== false) {
@ -1093,8 +1093,8 @@ class Indexer
}
fclose($fh);
if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
chmod($fn . '.tmp', $conf['fperm']);
io_rename($fn . '.tmp', $fn . '.idx');
return true;
}
@ -1155,9 +1155,9 @@ class Indexer
$idx = [];
if (is_array($filter)) {
// testing if index files exist only
$path = $conf['indexdir']."/i";
$path = $conf['indexdir'] . "/i";
foreach (array_keys($filter) as $key) {
if (file_exists($path.$key.'.idx'))
if (file_exists($path . $key . '.idx'))
$idx[] = $key;
}
} else {
@ -1184,12 +1184,12 @@ class Indexer
protected function updateTuple($line, $id, $count)
{
if ($line != '') {
$line = preg_replace('/(^|:)'.preg_quote($id, '/').'\*\d*/', '', $line);
$line = preg_replace('/(^|:)' . preg_quote($id, '/') . '\*\d*/', '', $line);
}
$line = trim($line, ':');
if ($count) {
if ($line) {
return "$id*$count:".$line;
return "$id*$count:" . $line;
} else {
return "$id*$count";
}

View File

@ -57,14 +57,14 @@ class Item
*/
public function toXML()
{
$result = ' <url>'.NL
.' <loc>'.hsc($this->url).'</loc>'.NL
.' <lastmod>'.date_iso8601($this->lastmod).'</lastmod>'.NL;
$result = ' <url>' . NL
. ' <loc>' . hsc($this->url) . '</loc>' . NL
. ' <lastmod>' . date_iso8601($this->lastmod) . '</lastmod>' . NL;
if ($this->changefreq !== null)
$result .= ' <changefreq>'.hsc($this->changefreq).'</changefreq>'.NL;
$result .= ' <changefreq>' . hsc($this->changefreq) . '</changefreq>' . NL;
if ($this->priority !== null)
$result .= ' <priority>'.hsc($this->priority).'</priority>'.NL;
$result .= ' </url>'.NL;
$result .= ' <priority>' . hsc($this->priority) . '</priority>' . NL;
$result .= ' </url>' . NL;
return $result;
}
}

View File

@ -47,7 +47,7 @@ class Mapper
if (
@filesize($sitemap) &&
@filemtime($sitemap) > (time()-($conf['sitemap']*86400))
@filemtime($sitemap) > (time() - ($conf['sitemap'] * 86400))
) { // 60*60*24=86400
Logger::debug('Sitemapper::generate(): Sitemap up to date');
return false;
@ -56,7 +56,7 @@ class Mapper
Logger::debug("Sitemapper::generate(): using $sitemap");
$pages = idx_get_indexer()->getPages();
Logger::debug('Sitemapper::generate(): creating sitemap using '.count($pages).' pages');
Logger::debug('Sitemapper::generate(): creating sitemap using ' . count($pages) . ' pages');
$items = [];
// build the sitemap items
@ -91,13 +91,13 @@ class Mapper
private function getXML($items)
{
ob_start();
echo '<?xml version="1.0" encoding="UTF-8"?>'.NL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'.NL;
echo '<?xml version="1.0" encoding="UTF-8"?>' . NL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . NL;
foreach ($items as $item) {
/** @var Item $item */
echo $item->toXML();
}
echo '</urlset>'.NL;
echo '</urlset>' . NL;
$result = ob_get_contents();
ob_end_clean();
return $result;
@ -114,7 +114,7 @@ class Mapper
{
global $conf;
$sitemap = $conf['cachedir'].'/sitemap.xml';
$sitemap = $conf['cachedir'] . '/sitemap.xml';
if (self::sitemapIsCompressed()) {
$sitemap .= '.gz';
}
@ -149,8 +149,8 @@ class Mapper
$encoded_sitemap_url = urlencode(wl('', ['do' => 'sitemap'], true, '&'));
$ping_urls = [
'google' => 'https://www.google.com/ping?sitemap='.$encoded_sitemap_url,
'yandex' => 'https://webmaster.yandex.com/ping?sitemap='.$encoded_sitemap_url
'google' => 'https://www.google.com/ping?sitemap=' . $encoded_sitemap_url,
'yandex' => 'https://webmaster.yandex.com/ping?sitemap=' . $encoded_sitemap_url
];
$data = [

View File

@ -27,7 +27,7 @@ class MediaSubscriptionSender extends SubscriptionSender
$trep = [
'MIME' => $mime,
'MEDIA' => ml($id, $current_rev?('rev='.$current_rev):'', true, '&', true),
'MEDIA' => ml($id, $current_rev ? ('rev=' . $current_rev) : '', true, '&', true),
'SIZE' => filesize_h(filesize($file)),
];

View File

@ -30,7 +30,7 @@ class PageSubscriptionSender extends SubscriptionSender
// prepare replacements (keys not set in hrep will be taken from trep)
$trep = [
'PAGE' => $id,
'NEWPAGE' => wl($id, $current_rev?('rev='.$current_rev):'', true, '&'),
'NEWPAGE' => wl($id, $current_rev ? ('rev=' . $current_rev) : '', true, '&'),
'SUMMARY' => $summary,
'SUBSCRIBE' => wl($id, ['do' => 'subscribe'], true, '&'),
];

View File

@ -77,7 +77,7 @@ class TaskRunner
{
$img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7');
header('Content-Type: image/gif');
header('Content-Length: '.strlen($img));
header('Content-Length: ' . strlen($img));
header('Connection: Close');
echo $img;
tpl_flush();

View File

@ -151,7 +151,7 @@ function auth_loadACL()
if (isset($USERINFO['grps'])) {
foreach ((array) $USERINFO['grps'] as $grp) {
$nid = str_replace('%GROUP%', cleanID($grp), $id);
$nrest = str_replace('%GROUP%', '@'.auth_nameencode($grp), $rest);
$nrest = str_replace('%GROUP%', '@' . auth_nameencode($grp), $rest);
$out[] = "$nid\t$nrest";
}
}
@ -319,9 +319,9 @@ function auth_cookiesalt($addsession = false, $secure = false)
return 'test';
}
global $conf;
$file = $conf['metadir'].'/_htcookiesalt';
$file = $conf['metadir'] . '/_htcookiesalt';
if ($secure || !file_exists($file)) {
$file = $conf['metadir'].'/_htcookiesalt2';
$file = $conf['metadir'] . '/_htcookiesalt2';
}
$salt = io_readFile($file);
if (empty($salt)) {
@ -383,7 +383,7 @@ function auth_encrypt($data, $secret)
for unique but necessarily random IVs. The resulting ciphertext is
compatible to ciphertext that was created using a "normal" IV.
*/
return $cipher->encrypt($iv.$data);
return $cipher->encrypt($iv . $data);
}
/**
@ -667,7 +667,7 @@ function auth_aclcheck_cb($data)
//prepend groups with @ and nameencode
foreach ($groups as &$group) {
$group = '@'.auth_nameencode($group);
$group = '@' . auth_nameencode($group);
}
$ns = getNS($id);
@ -680,7 +680,7 @@ function auth_aclcheck_cb($data)
if ($user) $groups[] = $user;
//check exact match first
$matches = preg_grep('/^'.preg_quote($id, '/').'[ \t]+([^ \t]+)[ \t]+/', $AUTH_ACL);
$matches = preg_grep('/^' . preg_quote($id, '/') . '[ \t]+([^ \t]+)[ \t]+/', $AUTH_ACL);
if (count($matches)) {
foreach ($matches as $match) {
$match = preg_replace('/#.*$/', '', $match); //ignore comments
@ -704,13 +704,13 @@ function auth_aclcheck_cb($data)
//still here? do the namespace checks
if ($ns) {
$path = $ns.':*';
$path = $ns . ':*';
} else {
$path = '*'; //root document
}
do {
$matches = preg_grep('/^'.preg_quote($path, '/').'[ \t]+([^ \t]+)[ \t]+/', $AUTH_ACL);
$matches = preg_grep('/^' . preg_quote($path, '/') . '[ \t]+([^ \t]+)[ \t]+/', $AUTH_ACL);
if (count($matches)) {
foreach ($matches as $match) {
$match = preg_replace('/#.*$/', '', $match); //ignore comments
@ -735,7 +735,7 @@ function auth_aclcheck_cb($data)
$ns = getNS($ns);
if ($path != '*') {
$path = $ns.':*';
$path = $ns . ':*';
if ($path == ':*') $path = '*';
} else {
//we did this already
@ -777,7 +777,7 @@ function auth_nameencode($name, $skip_group = false)
if (!isset($cache[$name][$skip_group])) {
if ($skip_group && $name[0] == '@') {
$cache[$name][$skip_group] = '@'.preg_replace_callback(
$cache[$name][$skip_group] = '@' . preg_replace_callback(
'/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f])/',
'auth_nameencode_callback',
substr($name, 1)
@ -802,7 +802,7 @@ function auth_nameencode($name, $skip_group = false)
*/
function auth_nameencode_callback($matches)
{
return '%'.dechex(ord(substr($matches[1], -1)));
return '%' . dechex(ord(substr($matches[1], -1)));
}
/**
@ -829,7 +829,7 @@ function auth_pwgen($foruser = '')
if ($evt->advise_before(true)) {
$c = 'bcdfghjklmnprstvwz'; //consonants except hard to speak ones
$v = 'aeiou'; //vowels
$a = $c.$v; //both
$a = $c . $v; //both
$s = '!$%&?+*~#-_:.;,'; // specials
//use thre syllables...
@ -839,7 +839,7 @@ function auth_pwgen($foruser = '')
$data['password'] .= $a[auth_random(0, strlen($a) - 1)];
}
//... and add a nice number and special
$data['password'] .= $s[auth_random(0, strlen($s) - 1)].auth_random(10, 99);
$data['password'] .= $s[auth_random(0, strlen($s) - 1)] . auth_random(10, 99);
}
$evt->advise_after();
@ -875,7 +875,7 @@ function auth_sendPassword($user, $password)
];
$mail = new Mailer();
$mail->to($mail->getCleanName($userinfo['name']).' <'.$userinfo['mail'].'>');
$mail->to($mail->getCleanName($userinfo['name']) . ' <' . $userinfo['mail'] . '>');
$mail->subject($lang['regpwmail']);
$mail->setBody($text, $trep);
return $mail->send();
@ -1125,7 +1125,7 @@ function act_resendpwd()
if ($token) {
// we're in token phase - get user info from token
$tfile = $conf['cachedir'].'/'.$token[0].'/'.$token.'.pwauth';
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
if (!file_exists($tfile)) {
msg($lang['resendpwdbadauth'], -1);
$INPUT->remove('pwauth');
@ -1197,8 +1197,8 @@ function act_resendpwd()
// generate auth token
$token = md5(auth_randombytes(16)); // random secret
$tfile = $conf['cachedir'].'/'.$token[0].'/'.$token.'.pwauth';
$url = wl('', ['do'=> 'resendpwd', 'pwauth'=> $token], true, '&');
$tfile = $conf['cachedir'] . '/' . $token[0] . '/' . $token . '.pwauth';
$url = wl('', ['do' => 'resendpwd', 'pwauth' => $token], true, '&');
io_saveFile($tfile, $user);
@ -1206,7 +1206,7 @@ function act_resendpwd()
$trep = ['FULLNAME' => $userinfo['name'], 'LOGIN' => $user, 'CONFIRM' => $url];
$mail = new Mailer();
$mail->to($userinfo['name'].' <'.$userinfo['mail'].'>');
$mail->to($userinfo['name'] . ' <' . $userinfo['mail'] . '>');
$mail->subject($lang['regpwmail']);
$mail->setBody($text, $trep);
if ($mail->send()) {
@ -1238,7 +1238,7 @@ function auth_cryptPassword($clear, $method = '', $salt = null)
if (empty($method)) $method = $conf['passcrypt'];
$pass = new PassHash();
$call = 'hash_'.$method;
$call = 'hash_' . $method;
if (!method_exists($pass, $call)) {
msg("Unsupported crypt method $method", -1);
@ -1282,7 +1282,7 @@ function auth_setCookie($user, $pass, $sticky)
$USERINFO = $auth->getUserData($user);
// set cookie
$cookie = base64_encode($user).'|'.((int) $sticky).'|'.base64_encode($pass);
$cookie = base64_encode($user) . '|' . ((int) $sticky) . '|' . base64_encode($pass);
$cookieDir = empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'];
$time = $sticky ? (time() + 60 * 60 * 24 * 365) : 0; //one year
setcookie(DOKU_COOKIE, $cookie, [

View File

@ -53,7 +53,7 @@ function addLogEntry(
$sizechange = null
) {
// no more used in DokuWiki core, but left for third-party plugins
dbg_deprecated('see '. PageFile::class .'::saveWikiText()');
dbg_deprecated('see ' . PageFile::class . '::saveWikiText()');
/** @var Input $INPUT */
global $INPUT;
@ -339,14 +339,14 @@ function _handleRecent($line, $ns, $flags, &$seen)
if (isHiddenPage($recent['id'])) return false;
// filter namespace
if (($ns) && (strpos($recent['id'], $ns.':') !== 0)) return false;
if (($ns) && (strpos($recent['id'], $ns . ':') !== 0)) return false;
// exclude subnamespaces
if (($flags & RECENTS_SKIP_SUBSPACES) && (getNS($recent['id']) != $ns)) return false;
// check ACL
if ($flags & RECENTS_MEDIA_CHANGES) {
$recent['perms'] = auth_quickaclcheck(getNS($recent['id']).':*');
$recent['perms'] = auth_quickaclcheck(getNS($recent['id']) . ':*');
} else {
$recent['perms'] = auth_quickaclcheck($recent['id']);
}

View File

@ -113,7 +113,7 @@ function getSecurityToken()
// CSRF checks are only for logged in users - do not generate for anonymous
if (trim($user) == '' || trim($session) == '') return '';
return PassHash::hmac('md5', $session.$user, auth_cookiesalt());
return PassHash::hmac('md5', $session . $user, auth_cookiesalt());
}
/**
@ -146,7 +146,7 @@ function checkSecurityToken($token = null)
*/
function formSecurityToken($print = true)
{
$ret = '<div class="no"><input type="hidden" name="sectok" value="'.getSecurityToken().'" /></div>'."\n";
$ret = '<div class="no"><input type="hidden" name="sectok" value="' . getSecurityToken() . '" /></div>' . "\n";
if ($print) echo $ret;
return $ret;
}
@ -358,7 +358,7 @@ function buildURLparams($params, $sep = '&amp;')
foreach ($params as $key => $val) {
if ($amp) $url .= $sep;
$url .= rawurlencode($key).'=';
$url .= rawurlencode($key) . '=';
$url .= rawurlencode((string) $val);
$amp = true;
}
@ -385,7 +385,7 @@ function buildAttributes($params, $skipEmptyStrings = false)
if ($val === '' && $skipEmptyStrings) continue;
if ($white) $url .= ' ';
$url .= $key.'="';
$url .= $key . '="';
$url .= hsc($val);
$url .= '"';
$white = true;
@ -527,17 +527,17 @@ function wl($id = '', $urlParameters = '', $absolute = false, $separator = '&amp
}
if ($conf['userewrite'] == 2) {
$xlink .= DOKU_SCRIPT.'/'.$id;
if ($urlParameters) $xlink .= '?'.$urlParameters;
$xlink .= DOKU_SCRIPT . '/' . $id;
if ($urlParameters) $xlink .= '?' . $urlParameters;
} elseif ($conf['userewrite']) {
$xlink .= $id;
if ($urlParameters) $xlink .= '?'.$urlParameters;
if ($urlParameters) $xlink .= '?' . $urlParameters;
} elseif ($id !== '') {
$xlink .= DOKU_SCRIPT.'?id='.$id;
if ($urlParameters) $xlink .= $separator.$urlParameters;
$xlink .= DOKU_SCRIPT . '?id=' . $id;
if ($urlParameters) $xlink .= $separator . $urlParameters;
} else {
$xlink .= DOKU_SCRIPT;
if ($urlParameters) $xlink .= '?'.$urlParameters;
if ($urlParameters) $xlink .= '?' . $urlParameters;
}
return $xlink;
@ -574,14 +574,14 @@ function exportlink($id = '', $format = 'raw', $urlParameters = '', $abs = false
}
if ($conf['userewrite'] == 2) {
$xlink .= DOKU_SCRIPT.'/'.$id.'?do=export_'.$format;
if ($urlParameters) $xlink .= $sep.$urlParameters;
$xlink .= DOKU_SCRIPT . '/' . $id . '?do=export_' . $format;
if ($urlParameters) $xlink .= $sep . $urlParameters;
} elseif ($conf['userewrite'] == 1) {
$xlink .= '_export/'.$format.'/'.$id;
if ($urlParameters) $xlink .= '?'.$urlParameters;
$xlink .= '_export/' . $format . '/' . $id;
if ($urlParameters) $xlink .= '?' . $urlParameters;
} else {
$xlink .= DOKU_SCRIPT.'?do=export_'.$format.$sep.'id='.$id;
if ($urlParameters) $xlink .= $sep.$urlParameters;
$xlink .= DOKU_SCRIPT . '?do=export_' . $format . $sep . 'id=' . $id;
if ($urlParameters) $xlink .= $sep . $urlParameters;
}
return $xlink;
@ -627,12 +627,12 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
} else {
$matches = [];
if (preg_match_all('/\b(w|h)=(\d*)\b/', $more, $matches, PREG_SET_ORDER) || $isexternalimage) {
$resize = ['w'=>0, 'h'=>0];
$resize = ['w' => 0, 'h' => 0];
foreach ($matches as $match) {
$resize[$match[1]] = $match[2];
}
$more .= $more === '' ? '' : $sep;
$more .= 'tok='.media_get_token($id, $resize['w'], $resize['h']);
$more .= 'tok=' . media_get_token($id, $resize['w'], $resize['h']);
}
$more = str_replace('cache=cache', '', $more); //skip default
$more = str_replace(',,', ',', $more);
@ -648,8 +648,8 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
// external URLs are always direct without rewriting
if ($isexternalimage) {
$xlink .= 'lib/exe/fetch.php';
$xlink .= '?'.$more;
$xlink .= $sep.'media='.rawurlencode($id);
$xlink .= '?' . $more;
$xlink .= $sep . 'media=' . rawurlencode($id);
return $xlink;
}
@ -670,13 +670,13 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
// build URL based on rewrite mode
if ($conf['userewrite']) {
$xlink .= $script.'/'.$id;
if ($more) $xlink .= '?'.$more;
$xlink .= $script . '/' . $id;
if ($more) $xlink .= '?' . $more;
} elseif ($more) {
$xlink .= $script.'?'.$more;
$xlink .= $sep.'media='.$id;
$xlink .= $script . '?' . $more;
$xlink .= $sep . 'media=' . $id;
} else {
$xlink .= $script.'?media='.$id;
$xlink .= $script . '?media=' . $id;
}
return $xlink;
@ -693,7 +693,7 @@ function ml($id = '', $more = '', $direct = true, $sep = '&amp;', $abs = false)
*/
function script()
{
return DOKU_BASE.DOKU_SCRIPT;
return DOKU_BASE . DOKU_SCRIPT;
}
/**
@ -759,7 +759,7 @@ function checkwordblock($text = '')
if (empty($block)) continue;
$re[] = $block;
}
if (count($re) && preg_match('#('.implode('|', $re).')#si', $text, $matches)) {
if (count($re) && preg_match('#(' . implode('|', $re) . ')#si', $text, $matches)) {
// prepare event data
$data = [];
$data['matches'] = $matches;
@ -819,7 +819,7 @@ function clientIP($single = false)
// skip trusted local addresses
foreach ($ip as $i) {
if (!empty($conf['trustedproxy']) && preg_match('/'.$conf['trustedproxy'].'/', $i)) {
if (!empty($conf['trustedproxy']) && preg_match('/' . $conf['trustedproxy'] . '/', $i)) {
continue;
} else {
return $i;
@ -828,7 +828,7 @@ function clientIP($single = false)
// still here? just use the last address
// this case all ips in the list are trusted
return $ip[count($ip)-1];
return $ip[count($ip) - 1];
}
/**
@ -967,7 +967,7 @@ function lock($id)
if ($INPUT->server->str('REMOTE_USER')) {
io_saveFile($lock, $INPUT->server->str('REMOTE_USER'));
} else {
io_saveFile($lock, clientIP()."\n".session_id());
io_saveFile($lock, clientIP() . "\n" . session_id());
}
}
@ -1093,14 +1093,14 @@ function pageTemplate($id)
// if the before event did not set a template file, try to find one
if (empty($data['tplfile'])) {
$path = dirname(wikiFN($id));
if (file_exists($path.'/_template.txt')) {
$data['tplfile'] = $path.'/_template.txt';
if (file_exists($path . '/_template.txt')) {
$data['tplfile'] = $path . '/_template.txt';
} else {
// search upper namespaces for templates
$len = strlen(rtrim($conf['datadir'], '/'));
while (strlen($path) >= $len) {
if (file_exists($path.'/__template.txt')) {
$data['tplfile'] = $path.'/__template.txt';
if (file_exists($path . '/__template.txt')) {
$data['tplfile'] = $path . '/__template.txt';
break;
}
$path = substr($path, 0, strrpos($path, '/'));
@ -1262,7 +1262,7 @@ function con($pre, $text, $suf, $pretty = false)
}
}
return $pre.$text.$suf;
return $pre . $text . $suf;
}
/**
@ -1278,7 +1278,7 @@ function con($pre, $text, $suf, $pretty = false)
*/
function detectExternalEdit($id)
{
dbg_deprecated(PageFile::class .'::detectExternalEdit()');
dbg_deprecated(PageFile::class . '::detectExternalEdit()');
(new PageFile($id))->detectExternalEdit();
}
@ -1327,7 +1327,7 @@ function saveWikiText($id, $text, $summary, $minor = false)
*/
function saveOldRevision($id)
{
dbg_deprecated(PageFile::class .'::saveOldRevision()');
dbg_deprecated(PageFile::class . '::saveOldRevision()');
return (new PageFile($id))->saveOldRevision();
}
@ -1442,7 +1442,7 @@ function filesize_h($size, $dec = 1)
$i++;
}
return round($size, $dec)."\xC2\xA0".$sizes[$i]; //non-breaking space
return round($size, $dec) . "\xC2\xA0" . $sizes[$i]; //non-breaking space
}
/**
@ -1517,7 +1517,7 @@ function date_iso8601($int_date)
{
$date_mod = date('Y-m-d\TH:i:s', $int_date);
$pre_timezone = date('O', $int_date);
$time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2);
$time_zone = substr($pre_timezone, 0, 3) . ":" . substr($pre_timezone, 3, 2);
$date_mod .= $time_zone;
return $date_mod;
}
@ -1560,7 +1560,7 @@ function obfuscate($email)
*/
function unslash($string, $char = "'")
{
return str_replace('\\'.$char, $char, $string);
return str_replace('\\' . $char, $char, $string);
}
/**
@ -1624,7 +1624,7 @@ function shorten($keep, $short, $max, $min = 9, $char = '…')
$max -= PhpString::strlen($keep);
if ($max < $min) return $keep;
$len = PhpString::strlen($short);
if ($len <= $max) return $keep.$short;
if ($len <= $max) return $keep . $short;
$half = floor($max / 2);
return $keep .
PhpString::substr($short, 0, $half - 1) .
@ -1685,9 +1685,9 @@ function userlink($username = null, $textonly = false)
if ($username === null) {
$data['username'] = $username = $INPUT->server->str('REMOTE_USER');
if ($textonly) {
$data['name'] = $INFO['userinfo']['name']. ' (' . $INPUT->server->str('REMOTE_USER') . ')';
$data['name'] = $INFO['userinfo']['name'] . ' (' . $INPUT->server->str('REMOTE_USER') . ')';
} else {
$data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> '.
$data['name'] = '<bdi>' . hsc($INFO['userinfo']['name']) . '</bdi> ' .
'(<bdi>' . hsc($INPUT->server->str('REMOTE_USER')) . '</bdi>)';
}
}
@ -1783,13 +1783,13 @@ function license_img($type)
if (!$conf['license']) return '';
if (!is_array($license[$conf['license']])) return '';
$try = [];
$try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.png';
$try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.gif';
$try[] = 'lib/images/license/' . $type . '/' . $conf['license'] . '.png';
$try[] = 'lib/images/license/' . $type . '/' . $conf['license'] . '.gif';
if (substr($conf['license'], 0, 3) == 'cc-') {
$try[] = 'lib/images/license/'.$type.'/cc.png';
$try[] = 'lib/images/license/' . $type . '/cc.png';
}
foreach ($try as $src) {
if (file_exists(DOKU_INC.$src)) return $src;
if (file_exists(DOKU_INC . $src)) return $src;
}
return '';
}
@ -1865,9 +1865,9 @@ function send_redirect($url)
(preg_match('|^Microsoft-IIS/(\d)\.\d$|', trim($INPUT->server->str('SERVER_SOFTWARE')), $matches)) &&
$matches[1] < 6
) {
header('Refresh: 0;url='.$url);
header('Refresh: 0;url=' . $url);
} else {
header('Location: '.$url);
header('Location: ' . $url);
}
// no exits during unit tests
@ -1929,7 +1929,7 @@ function get_doku_pref($pref, $default)
// due to #2721 there might be duplicate entries,
// so we read from the end
for ($i = $cnt-2; $i >= 0; $i -= 2) {
for ($i = $cnt - 2; $i >= 0; $i -= 2) {
if ($parts[$i] === $enc_pref) {
return urldecode($parts[$i + 1]);
}

View File

@ -123,7 +123,7 @@ function getInterwiki()
$wikis = array_filter($wikis, 'strlen');
//add sepecial case 'this'
$wikis['this'] = DOKU_URL.'{NAME}';
$wikis['this'] = DOKU_URL . '{NAME}';
}
return $wikis;
}
@ -311,7 +311,7 @@ function retrieveConfig($type, $fn, $params = null, $combine = 'array_merge')
if (!is_array($params)) $params = [];
$combined = [];
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"', E_USER_WARNING);
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "' . $type . '"', E_USER_WARNING);
foreach (['default', 'local', 'protected'] as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
foreach ($config_cascade[$type][$config_group] as $file) {
@ -338,7 +338,7 @@ function getConfigFiles($type)
global $config_cascade;
$files = [];
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"', E_USER_WARNING);
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "' . $type . '"', E_USER_WARNING);
foreach (['default', 'local', 'protected'] as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
$files = array_merge($files, $config_cascade[$type][$config_group]);
@ -441,9 +441,9 @@ function conf_encodeString($str, $code)
{
switch ($code) {
case 'base64':
return '<b>'.base64_encode($str);
return '<b>' . base64_encode($str);
case 'uuencode':
return '<u>'.convert_uuencode($str);
return '<u>' . convert_uuencode($str);
case 'plain':
default:
return $str;

View File

@ -52,12 +52,12 @@ function sendFile($file, $mime, $dl, $cache, $public = false, $orig = null, $csp
if ($maxage) {
if ($public) {
// cache publically
header('Expires: '.gmdate("D, d M Y H:i:s", $expires).' GMT');
header('Cache-Control: public, proxy-revalidate, no-transform, max-age='.$maxage);
header('Expires: ' . gmdate("D, d M Y H:i:s", $expires) . ' GMT');
header('Cache-Control: public, proxy-revalidate, no-transform, max-age=' . $maxage);
} else {
// cache in browser
header('Expires: '.gmdate("D, d M Y H:i:s", $expires).' GMT');
header('Cache-Control: private, no-transform, max-age='.$maxage);
header('Expires: ' . gmdate("D, d M Y H:i:s", $expires) . ' GMT');
header('Cache-Control: private, no-transform, max-age=' . $maxage);
}
} else {
// no cache at all
@ -124,9 +124,9 @@ function rfc2231_encode($name, $value, $charset = 'utf-8', $lang = 'en')
$value
);
if ($value != $internal) {
return ' '.$name.'*='.$charset."'".$lang."'".$internal;
return ' ' . $name . '*=' . $charset . "'" . $lang . "'" . $internal;
} else {
return ' '.$name.'="'.$value.'"';
return ' ' . $name . '="' . $value . '"';
}
}
@ -172,7 +172,7 @@ function checkFileStatus(&$media, &$file, $rev = '', $width = 0, $height = 0)
}
//check permissions (namespace only)
if (auth_quickaclcheck(getNS($media).':X') < AUTH_READ) {
if (auth_quickaclcheck(getNS($media) . ':X') < AUTH_READ) {
return [403, 'Forbidden'];
}
$file = mediaFN($media, $rev);

View File

@ -99,9 +99,9 @@ class Doku_Form
public function startFieldset($legend)
{
if ($this->_infieldset) {
$this->addElement(array('_elem'=>'closefieldset'));
$this->addElement(array('_elem' => 'closefieldset'));
}
$this->addElement(array('_elem'=>'openfieldset', '_legend'=>$legend));
$this->addElement(array('_elem' => 'openfieldset', '_legend' => $legend));
$this->_infieldset = true;
}
@ -113,7 +113,7 @@ class Doku_Form
public function endFieldset()
{
if ($this->_infieldset) {
$this->addElement(array('_elem'=>'closefieldset'));
$this->addElement(array('_elem' => 'closefieldset'));
}
$this->_infieldset = false;
}
@ -278,23 +278,23 @@ class Doku_Form
global $lang;
$form = '';
$this->params['accept-charset'] = $lang['encoding'];
$form .= '<form '. buildAttributes($this->params, false) .'><div class="no">'. DOKU_LF;
$form .= '<form ' . buildAttributes($this->params, false) . '><div class="no">' . DOKU_LF;
if (!empty($this->_hidden)) {
foreach ($this->_hidden as $name => $value)
$form .= form_hidden(array('name'=>$name, 'value'=>$value));
$form .= form_hidden(array('name' => $name, 'value' => $value));
}
foreach ($this->_content as $element) {
if (is_array($element)) {
$elem_type = $element['_elem'];
if (function_exists('form_'.$elem_type)) {
$form .= call_user_func('form_'.$elem_type, $element).DOKU_LF;
if (function_exists('form_' . $elem_type)) {
$form .= call_user_func('form_' . $elem_type, $element) . DOKU_LF;
}
} else {
$form .= $element;
}
}
if ($this->_infieldset) $form .= form_closefieldset().DOKU_LF;
$form .= '</div></form>'.DOKU_LF;
if ($this->_infieldset) $form .= form_closefieldset() . DOKU_LF;
$form .= '</div></form>' . DOKU_LF;
return $form;
}
@ -346,7 +346,7 @@ class Doku_Form
*/
function form_makeTag($tag, $attrs = array())
{
$elem = array('_elem'=>'tag', '_tag'=>$tag);
$elem = array('_elem' => 'tag', '_tag' => $tag);
return array_merge($elem, $attrs);
}
@ -364,7 +364,7 @@ function form_makeTag($tag, $attrs = array())
*/
function form_makeOpenTag($tag, $attrs = array())
{
$elem = array('_elem'=>'opentag', '_tag'=>$tag);
$elem = array('_elem' => 'opentag', '_tag' => $tag);
return array_merge($elem, $attrs);
}
@ -381,7 +381,7 @@ function form_makeOpenTag($tag, $attrs = array())
*/
function form_makeCloseTag($tag)
{
return array('_elem'=>'closetag', '_tag'=>$tag);
return array('_elem' => 'closetag', '_tag' => $tag);
}
/**
@ -400,8 +400,8 @@ function form_makeCloseTag($tag)
*/
function form_makeWikiText($text, $attrs = array())
{
$elem = array('_elem'=>'wikitext', '_text'=>$text,
'class'=>'edit', 'cols'=>'80', 'rows'=>'10');
$elem = array('_elem' => 'wikitext', '_text' => $text,
'class' => 'edit', 'cols' => '80', 'rows' => '10');
return array_merge($elem, $attrs);
}
@ -423,10 +423,10 @@ function form_makeWikiText($text, $attrs = array())
function form_makeButton($type, $act, $value = '', $attrs = array())
{
if ($value == '') $value = $act;
$elem = array('_elem'=>'button', 'type'=>$type, '_action'=>$act,
'value'=>$value);
$elem = array('_elem' => 'button', 'type' => $type, '_action' => $act,
'value' => $value);
if (!empty($attrs['accesskey']) && empty($attrs['title'])) {
$attrs['title'] = $value .' ['. strtoupper($attrs['accesskey']) .']';
$attrs['title'] = $value . ' [' . strtoupper($attrs['accesskey']) . ']';
}
return array_merge($elem, $attrs);
}
@ -453,8 +453,8 @@ function form_makeButton($type, $act, $value = '', $attrs = array())
function form_makeField($type, $name, $value = '', $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
$elem = array('_elem'=>'field', '_text'=>$label, '_class'=>$class,
'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value);
$elem = array('_elem' => 'field', '_text' => $label, '_class' => $class,
'type' => $type, 'id' => $id, 'name' => $name, 'value' => $value);
return array_merge($elem, $attrs);
}
@ -480,8 +480,8 @@ function form_makeField($type, $name, $value = '', $label = null, $id = '', $cla
function form_makeFieldRight($type, $name, $value = '', $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
$elem = array('_elem'=>'fieldright', '_text'=>$label, '_class'=>$class,
'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value);
$elem = array('_elem' => 'fieldright', '_text' => $label, '_class' => $class,
'type' => $type, 'id' => $id, 'name' => $name, 'value' => $value);
return array_merge($elem, $attrs);
}
@ -505,8 +505,8 @@ function form_makeFieldRight($type, $name, $value = '', $label = null, $id = '',
function form_makeTextField($name, $value = '', $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
$elem = array('_elem'=>'textfield', '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name, 'value'=>$value, 'class'=>'edit');
$elem = array('_elem' => 'textfield', '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name, 'value' => $value, 'class' => 'edit');
return array_merge($elem, $attrs);
}
@ -530,8 +530,8 @@ function form_makeTextField($name, $value = '', $label = null, $id = '', $class
function form_makePasswordField($name, $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
$elem = array('_elem'=>'passwordfield', '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name, 'class'=>'edit');
$elem = array('_elem' => 'passwordfield', '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name, 'class' => 'edit');
return array_merge($elem, $attrs);
}
@ -554,8 +554,8 @@ function form_makePasswordField($name, $label = null, $id = '', $class = '', $at
function form_makeFileField($name, $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
$elem = array('_elem'=>'filefield', '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name, 'class'=>'edit');
$elem = array('_elem' => 'filefield', '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name, 'class' => 'edit');
return array_merge($elem, $attrs);
}
@ -581,9 +581,9 @@ function form_makeFileField($name, $label = null, $id = '', $class = '', $attrs
function form_makeCheckboxField($name, $value = '1', $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
if (is_null($value) || $value=='') $value='0';
$elem = array('_elem'=>'checkboxfield', '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name, 'value'=>$value);
if (is_null($value) || $value == '') $value = '0';
$elem = array('_elem' => 'checkboxfield', '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name, 'value' => $value);
return array_merge($elem, $attrs);
}
@ -607,9 +607,9 @@ function form_makeCheckboxField($name, $value = '1', $label = null, $id = '', $c
function form_makeRadioField($name, $value = '1', $label = null, $id = '', $class = '', $attrs = array())
{
if (is_null($label)) $label = $name;
if (is_null($value) || $value=='') $value='0';
$elem = array('_elem'=>'radiofield', '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name, 'value'=>$value);
if (is_null($value) || $value == '') $value = '0';
$elem = array('_elem' => 'radiofield', '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name, 'value' => $value);
return array_merge($elem, $attrs);
}
@ -645,7 +645,7 @@ function form_makeMenuField($name, $values, $selected = '', $label = null, $id =
// FIXME: php doesn't know the difference between a string and an integer
if (is_string(key($values))) {
foreach ($values as $val => $text) {
$options[] = array($val, $text, (!is_null($selected) && $val==$selected));
$options[] = array($val, $text, (!is_null($selected) && $val == $selected));
}
} else {
if (is_integer($selected)) $selected = $values[$selected];
@ -653,11 +653,11 @@ function form_makeMenuField($name, $values, $selected = '', $label = null, $id =
if (is_array($val))
@list($val, $text) = $val;
else $text = null;
$options[] = array($val, $text, $val===$selected);
$options[] = array($val, $text, $val === $selected);
}
}
$elem = array('_elem'=>'menufield', '_options'=>$options, '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name);
$elem = array('_elem' => 'menufield', '_options' => $options, '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name);
return array_merge($elem, $attrs);
}
@ -709,8 +709,8 @@ function form_makeListboxField($name, $values, $selected = '', $label = null, $i
$options[] = array($val, $text, in_array($val, $selected), $disabled);
}
}
$elem = array('_elem'=>'listboxfield', '_options'=>$options, '_text'=>$label, '_class'=>$class,
'id'=>$id, 'name'=>$name);
$elem = array('_elem' => 'listboxfield', '_options' => $options, '_text' => $label, '_class' => $class,
'id' => $id, 'name' => $name);
return array_merge($elem, $attrs);
}
@ -728,7 +728,7 @@ function form_makeListboxField($name, $values, $selected = '', $label = null, $i
*/
function form_tag($attrs)
{
return '<'.$attrs['_tag'].' '. buildAttributes($attrs, true) .'/>';
return '<' . $attrs['_tag'] . ' ' . buildAttributes($attrs, true) . '/>';
}
/**
@ -745,7 +745,7 @@ function form_tag($attrs)
*/
function form_opentag($attrs)
{
return '<'.$attrs['_tag'].' '. buildAttributes($attrs, true) .'>';
return '<' . $attrs['_tag'] . ' ' . buildAttributes($attrs, true) . '>';
}
/**
@ -762,7 +762,7 @@ function form_opentag($attrs)
*/
function form_closetag($attrs)
{
return '</'.$attrs['_tag'].'>';
return '</' . $attrs['_tag'] . '>';
}
/**
@ -779,8 +779,8 @@ function form_closetag($attrs)
*/
function form_openfieldset($attrs)
{
$s = '<fieldset '. buildAttributes($attrs, true) .'>';
if (!is_null($attrs['_legend'])) $s .= '<legend>'.$attrs['_legend'].'</legend>';
$s = '<fieldset ' . buildAttributes($attrs, true) . '>';
if (!is_null($attrs['_legend'])) $s .= '<legend>' . $attrs['_legend'] . '</legend>';
return $s;
}
@ -813,7 +813,7 @@ function form_closefieldset()
*/
function form_hidden($attrs)
{
return '<input type="hidden" name="'.$attrs['name'].'" value="'. formText($attrs['value']) .'" />';
return '<input type="hidden" name="' . $attrs['name'] . '" value="' . formText($attrs['value']) . '" />';
}
/**
@ -834,9 +834,9 @@ function form_wikitext($attrs)
unset($attrs['name']);
unset($attrs['id']);
return '<textarea name="wikitext" id="wiki__text" dir="auto" '
. buildAttributes($attrs, true).'>'.DOKU_LF
. buildAttributes($attrs, true) . '>' . DOKU_LF
. formText($attrs['_text'])
.'</textarea>';
. '</textarea>';
}
/**
@ -853,10 +853,10 @@ function form_wikitext($attrs)
*/
function form_button($attrs)
{
$p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : '';
$p = (!empty($attrs['_action'])) ? 'name="do[' . $attrs['_action'] . ']" ' : '';
$value = $attrs['value'];
unset($attrs['value']);
return '<button '.$p. buildAttributes($attrs, true) .'>'.$value.'</button>';
return '<button ' . $p . buildAttributes($attrs, true) . '>' . $value . '</button>';
}
/**
@ -875,10 +875,10 @@ function form_button($attrs)
function form_field($attrs)
{
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span>';
$s .= ' <input '. buildAttributes($attrs, true) .' /></label>';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span>';
$s .= ' <input ' . buildAttributes($attrs, true) . ' /></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -900,10 +900,10 @@ function form_field($attrs)
function form_fieldright($attrs)
{
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><input '. buildAttributes($attrs, true) .' />';
$s .= ' <span>'.$attrs['_text'].'</span></label>';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><input ' . buildAttributes($attrs, true) . ' />';
$s .= ' <span>' . $attrs['_text'] . '</span></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -927,10 +927,10 @@ function form_textfield($attrs)
// mandatory attributes
unset($attrs['type']);
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span> ';
$s .= '<input type="text" '. buildAttributes($attrs, true) .' /></label>';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span> ';
$s .= '<input type="text" ' . buildAttributes($attrs, true) . ' /></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -954,10 +954,10 @@ function form_passwordfield($attrs)
// mandatory attributes
unset($attrs['type']);
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span> ';
$s .= '<input type="password" '. buildAttributes($attrs, true) .' /></label>';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span> ';
$s .= '<input type="password" ' . buildAttributes($attrs, true) . ' /></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -981,12 +981,12 @@ function form_passwordfield($attrs)
function form_filefield($attrs)
{
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span> ';
$s .= '<input type="file" '. buildAttributes($attrs, true);
if (!empty($attrs['_maxlength'])) $s .= ' maxlength="'.$attrs['_maxlength'].'"';
if (!empty($attrs['_accept'])) $s .= ' accept="'.$attrs['_accept'].'"';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span> ';
$s .= '<input type="file" ' . buildAttributes($attrs, true);
if (!empty($attrs['_maxlength'])) $s .= ' maxlength="' . $attrs['_maxlength'] . '"';
if (!empty($attrs['_accept'])) $s .= ' accept="' . $attrs['_accept'] . '"';
$s .= ' /></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
@ -1013,16 +1013,16 @@ function form_checkboxfield($attrs)
// mandatory attributes
unset($attrs['type']);
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '>';
if (is_array($attrs['value'])) {
echo '<input type="hidden" name="'. hsc($attrs['name']) .'"'
.' value="'. hsc($attrs['value'][1]) .'" />';
echo '<input type="hidden" name="' . hsc($attrs['name']) . '"'
. ' value="' . hsc($attrs['value'][1]) . '" />';
$attrs['value'] = $attrs['value'][0];
}
$s .= '<input type="checkbox" '. buildAttributes($attrs, true) .' />';
$s .= ' <span>'.$attrs['_text'].'</span></label>';
$s .= '<input type="checkbox" ' . buildAttributes($attrs, true) . ' />';
$s .= ' <span>' . $attrs['_text'] . '</span></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -1046,10 +1046,10 @@ function form_radiofield($attrs)
// mandatory attributes
unset($attrs['type']);
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><input type="radio" '. buildAttributes($attrs, true) .' />';
$s .= ' <span>'.$attrs['_text'].'</span></label>';
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><input type="radio" ' . buildAttributes($attrs, true) . ' />';
$s .= ' <span>' . $attrs['_text'] . '</span></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -1075,30 +1075,30 @@ function form_menufield($attrs)
{
$attrs['size'] = '1';
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span>';
$s .= ' <select '. buildAttributes($attrs, true) .'>'.DOKU_LF;
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span>';
$s .= ' <select ' . buildAttributes($attrs, true) . '>' . DOKU_LF;
if (!empty($attrs['_options'])) {
$selected = false;
$cnt = count($attrs['_options']);
for ($n=0; $n < $cnt; $n++) {
for ($n = 0; $n < $cnt; $n++) {
@list($value,$text,$select) = $attrs['_options'][$n];
$p = '';
if (!is_null($text))
$p .= ' value="'. formText($value) .'"';
$p .= ' value="' . formText($value) . '"';
else $text = $value;
if (!empty($select) && !$selected) {
$p .= ' selected="selected"';
$selected = true;
}
$s .= '<option'.$p.'>'. formText($text) .'</option>';
$s .= '<option' . $p . '>' . formText($text) . '</option>';
}
} else {
$s .= '<option></option>';
}
$s .= DOKU_LF.'</select></label>';
$s .= DOKU_LF . '</select></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;
@ -1122,24 +1122,24 @@ function form_menufield($attrs)
function form_listboxfield($attrs)
{
$s = '<label';
if ($attrs['_class']) $s .= ' class="'.$attrs['_class'].'"';
if (!empty($attrs['id'])) $s .= ' for="'.$attrs['id'].'"';
$s .= '><span>'.$attrs['_text'].'</span> ';
$s .= '<select '. buildAttributes($attrs, true) .'>'.DOKU_LF;
if ($attrs['_class']) $s .= ' class="' . $attrs['_class'] . '"';
if (!empty($attrs['id'])) $s .= ' for="' . $attrs['id'] . '"';
$s .= '><span>' . $attrs['_text'] . '</span> ';
$s .= '<select ' . buildAttributes($attrs, true) . '>' . DOKU_LF;
if (!empty($attrs['_options'])) {
foreach ($attrs['_options'] as $opt) {
@list($value, $text, $select, $disabled) = $opt;
$p = '';
if (is_null($text)) $text = $value;
$p .= ' value="'. formText($value) .'"';
$p .= ' value="' . formText($value) . '"';
if (!empty($select)) $p .= ' selected="selected"';
if ($disabled) $p .= ' disabled="disabled"';
$s .= '<option'.$p.'>'. formText($text) .'</option>';
$s .= '<option' . $p . '>' . formText($text) . '</option>';
}
} else {
$s .= '<option></option>';
}
$s .= DOKU_LF.'</select></label>';
$s .= DOKU_LF . '</select></label>';
if (preg_match('/(^| )block($| )/', $attrs['_class']))
$s .= '<br />';
return $s;

View File

@ -477,11 +477,11 @@ function ft_snippet($id, $highlight)
$re2 = "$re1.{0,75}(?!\\1)$re1";
$re3 = "$re1.{0,45}(?!\\1)$re1.{0,45}(?!\\1)(?!\\2)$re1";
for ($cnt=4; $cnt--;) {
for ($cnt = 4; $cnt--;) {
if (0) {
} elseif (preg_match('/'.$re3.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} elseif (preg_match('/'.$re2.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} elseif (preg_match('/'.$re1.'/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} elseif (preg_match('/' . $re3 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} elseif (preg_match('/' . $re2 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} elseif (preg_match('/' . $re1 . '/iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) {
} else {
break;
}
@ -495,16 +495,16 @@ function ft_snippet($id, $highlight)
// establish context, 100 bytes surrounding the match string
// first look to see if we can go 100 either side,
// then drop to 50 adding any excess if the other side can't go to 50,
$pre = min($utf8_idx-$utf8_offset, 100);
$post = min($len-$utf8_idx-$utf8_len, 100);
$pre = min($utf8_idx - $utf8_offset, 100);
$post = min($len - $utf8_idx - $utf8_len, 100);
if ($pre>50 && $post>50) {
if ($pre > 50 && $post > 50) {
$pre = 50;
$post = 50;
} elseif ($pre>50) {
$pre = min($pre, 100-$post);
} elseif ($post>50) {
$post = min($post, 100-$pre);
} elseif ($pre > 50) {
$pre = min($pre, 100 - $post);
} elseif ($post > 50) {
$post = min($post, 100 - $pre);
} elseif ($offset == 0) {
// both are less than 50, means the context is the whole string
// make it so and break out of this loop - there is no need for the
@ -520,9 +520,9 @@ function ft_snippet($id, $highlight)
$end = $utf8_idx + $utf8_len + $post; // now set it to the end of this context
if ($append) {
$snippets[count($snippets)-1] .= PhpString::substr($text, $append, $end-$append);
$snippets[count($snippets) - 1] .= PhpString::substr($text, $append, $end - $append);
} else {
$snippets[] = PhpString::substr($text, $start, $end-$start);
$snippets[] = PhpString::substr($text, $start, $end - $start);
}
// set $offset for next match attempt
@ -536,7 +536,7 @@ function ft_snippet($id, $highlight)
}
$m = "\1";
$snippets = preg_replace('/'.$re1.'/iu', $m.'$1'.$m, $snippets);
$snippets = preg_replace('/' . $re1 . '/iu', $m . '$1' . $m, $snippets);
$snippet = preg_replace(
'/' . $m . '([^' . $m . ']*?)' . $m . '/iu',
'<strong class="search_hit">$1</strong>',
@ -576,7 +576,7 @@ function ft_snippet_re_preprocess($term)
if (substr($term, 0, 2) == '\\*') {
$term = substr($term, 2);
} else {
$term = $BL.$term;
$term = $BL . $term;
}
if (substr($term, -2, 2) == '\\*') {
@ -585,7 +585,7 @@ function ft_snippet_re_preprocess($term)
$term .= $BR;
}
if ($term == $BL || $term == $BR || $term == $BL.$BR) $term = '';
if ($term == $BL || $term == $BR || $term == $BL . $BR) $term = '';
return $term;
}
@ -737,7 +737,7 @@ function ft_queryParser($Indexer, $query)
if (preg_match('/^(-?)"(.+)"$/u', $term, $matches)) {
// phrase-include and phrase-exclude
$not = $matches[1] ? 'NOT' : '';
$parsed = $not.ft_termParser($Indexer, $matches[2], false, true);
$parsed = $not . ft_termParser($Indexer, $matches[2], false, true);
} else {
// fix incomplete phrase
$term = str_replace('"', ' ', $term);
@ -778,13 +778,13 @@ function ft_queryParser($Indexer, $query)
$parsed .= 'OR';
} elseif (preg_match('/^(?:\^|-ns:)(.+)$/u', $token, $matches)) {
// namespace-exclude
$parsed .= 'NOT(N+:'.$matches[1].')';
$parsed .= 'NOT(N+:' . $matches[1] . ')';
} elseif (preg_match('/^(?:@|ns:)(.+)$/u', $token, $matches)) {
// namespace-include
$parsed .= '(N+:'.$matches[1].')';
$parsed .= '(N+:' . $matches[1] . ')';
} elseif (preg_match('/^-(.+)$/', $token, $matches)) {
// word-exclude
$parsed .= 'NOT('.ft_termParser($Indexer, $matches[1]).')';
$parsed .= 'NOT(' . ft_termParser($Indexer, $matches[1]) . ')';
} else {
// word-include
$parsed .= ft_termParser($Indexer, $token);
@ -945,12 +945,12 @@ function ft_termParser($Indexer, $term, $consider_asian = true, $phrase_mode = f
if (empty($words)) {
$parsed = '()'; // important: do not remove
} elseif ($words[0] === $term) {
$parsed = '(W+:'.$words[0].')';
$parsed = '(W+:' . $words[0] . ')';
} elseif ($phrase_mode) {
$term_encoded = str_replace(['(', ')'], ['OP', 'CP'], $term);
$parsed = '((W_:'.implode(')(W_:', $words).')(P+:'.$term_encoded.'))';
$parsed = '((W_:' . implode(')(W_:', $words) . ')(P+:' . $term_encoded . '))';
} else {
$parsed = '((W+:'.implode(')(W+:', $words).'))';
$parsed = '((W+:' . implode(')(W+:', $words) . '))';
}
}
return $parsed;

View File

@ -62,7 +62,7 @@ function html_wikilink($id, $name = null, $search = '')
*/
function html_login($svg = false)
{
dbg_deprecated(Login::class .'::show()');
dbg_deprecated(Login::class . '::show()');
(new Login($svg))->show();
}
@ -74,7 +74,7 @@ function html_login($svg = false)
*/
function html_denied()
{
dbg_deprecated(Denied::class .'::showBanner()');
dbg_deprecated(Denied::class . '::showBanner()');
(new Denied())->showBanner();
}
@ -154,13 +154,13 @@ function html_secedit_get_button($data)
unset($data['secid']);
$params = array_merge(
['do' => 'edit', 'rev' => $INFO['lastmod'], 'summary' => '['.$name.'] '],
['do' => 'edit', 'rev' => $INFO['lastmod'], 'summary' => '[' . $name . '] '],
$data
);
$html = '<div class="secedit editbutton_'.$data['target'] .' editbutton_'.$secid .'">';
$html.= html_btn('secedit', $ID, '', $params, 'post', $name);
$html.= '</div>';
$html = '<div class="secedit editbutton_' . $data['target'] . ' editbutton_' . $secid . '">';
$html .= html_btn('secedit', $ID, '', $params, 'post', $name);
$html .= '</div>';
return $html;
}
@ -176,9 +176,9 @@ function html_topbtn()
global $lang;
return '<a class="nolink" href="#dokuwiki__top">'
.'<button class="button" onclick="window.scrollTo(0, 0)" title="'. $lang['btn_top'] .'">'
. '<button class="button" onclick="window.scrollTo(0, 0)" title="' . $lang['btn_top'] . '">'
. $lang['btn_top']
.'</button></a>';
. '</button></a>';
}
/**
@ -203,26 +203,26 @@ function html_btn($name, $id, $akey, $params, $method = 'get', $tooltip = '', $l
global $lang;
if (!$label)
$label = $lang['btn_'.$name];
$label = $lang['btn_' . $name];
//filter id (without urlencoding)
$id = idfilter($id, false);
//make nice URLs even for buttons
if ($conf['userewrite'] == 2) {
$script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
$script = DOKU_BASE . DOKU_SCRIPT . '/' . $id;
} elseif ($conf['userewrite']) {
$script = DOKU_BASE.$id;
$script = DOKU_BASE . $id;
} else {
$script = DOKU_BASE.DOKU_SCRIPT;
$script = DOKU_BASE . DOKU_SCRIPT;
$params['id'] = $id;
}
$html = '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
$html = '<form class="button btn_' . $name . '" method="' . $method . '" action="' . $script . '"><div class="no">';
if (is_array($params)) {
foreach ($params as $key => $val) {
$html .= '<input type="hidden" name="'.$key.'" value="'.hsc($val).'" />';
$html .= '<input type="hidden" name="' . $key . '" value="' . hsc($val) . '" />';
}
}
@ -230,12 +230,12 @@ function html_btn($name, $id, $akey, $params, $method = 'get', $tooltip = '', $l
$html .= '<button type="submit" ';
if ($akey) {
$tip .= ' ['.strtoupper($akey).']';
$html .= 'accesskey="'.$akey.'" ';
$tip .= ' [' . strtoupper($akey) . ']';
$html .= 'accesskey="' . $akey . '" ';
}
$html .= 'title="'.$tip.'">';
$html .= 'title="' . $tip . '">';
if ($svg) {
$html .= '<span>'. hsc($label) .'</span>'. inlineSVG($svg);
$html .= '<span>' . hsc($label) . '</span>' . inlineSVG($svg);
} else {
$html .= hsc($label);
}
@ -252,7 +252,7 @@ function html_btn($name, $id, $akey, $params, $method = 'get', $tooltip = '', $l
*/
function html_showrev()
{
dbg_deprecated(PageView::class .'::showrev()');
dbg_deprecated(PageView::class . '::showrev()');
}
/**
@ -265,7 +265,7 @@ function html_showrev()
*/
function html_show($txt = null)
{
dbg_deprecated(PageView::class .'::show()');
dbg_deprecated(PageView::class . '::show()');
(new PageView($txt))->show();
}
@ -277,7 +277,7 @@ function html_show($txt = null)
*/
function html_draft()
{
dbg_deprecated(PageDraft::class .'::show()');
dbg_deprecated(PageDraft::class . '::show()');
(new PageDraft())->show();
}
@ -306,7 +306,7 @@ function html_hilight($html, $phrases)
return @preg_replace_callback("/((<[^>]*)|$regex)/ui", function ($match) {
$hlight = unslash($match[0]);
if (!isset($match[2])) {
$hlight = '<span class="search_hit">'.$hlight.'</span>';
$hlight = '<span class="search_hit">' . $hlight . '</span>';
}
return $hlight;
}, $html);
@ -320,7 +320,7 @@ function html_hilight($html, $phrases)
*/
function html_locked()
{
dbg_deprecated(Locked::class .'::showBanner()');
dbg_deprecated(Locked::class . '::showBanner()');
(new Locked())->showBanner();
}
@ -337,7 +337,7 @@ function html_locked()
*/
function html_revisions($first = -1, $media_id = '')
{
dbg_deprecated(PageRevisions::class .'::show()');
dbg_deprecated(PageRevisions::class . '::show()');
if ($media_id) {
(new MediaRevisions($media_id))->show($first);
} else {
@ -360,7 +360,7 @@ function html_revisions($first = -1, $media_id = '')
*/
function html_recent($first = 0, $show_changes = 'both')
{
dbg_deprecated(Recent::class .'::show()');
dbg_deprecated(Recent::class . '::show()');
(new Recent($first, $show_changes))->show();
}
@ -374,7 +374,7 @@ function html_recent($first = 0, $show_changes = 'both')
*/
function html_index($ns)
{
dbg_deprecated(Index::class .'::show()');
dbg_deprecated(Index::class . '::show()');
(new Index($ns))->show();
}
@ -391,7 +391,7 @@ function html_index($ns)
*/
function html_list_index($item)
{
dbg_deprecated(Index::class .'::formatListItem()');
dbg_deprecated(Index::class . '::formatListItem()');
return (new Index())->formatListItem($item);
}
@ -410,7 +410,7 @@ function html_list_index($item)
*/
function html_li_index($item)
{
dbg_deprecated(Index::class .'::tagListItem()');
dbg_deprecated(Index::class . '::tagListItem()');
return (new Index())->tagListItem($item);
}
@ -425,7 +425,7 @@ function html_li_index($item)
*/
function html_li_default($item)
{
return '<li class="level'.$item['level'].'">';
return '<li class="level' . $item['level'] . '">';
}
/**
@ -465,7 +465,7 @@ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = fa
// set callback function to build the <li> tag, formerly defined as html_li_default()
if (!is_callable($lifunc)) {
$lifunc = static fn($item) => '<li class="level'.$item['level'].'">';
$lifunc = static fn($item) => '<li class="level' . $item['level'] . '">';
}
foreach ($data as $item) {
@ -473,22 +473,22 @@ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = fa
//open new list
for ($i = 0; $i < ($item['level'] - $level); $i++) {
if ($i) $html .= '<li class="clear">';
$html .= "\n".'<ul class="'.$class.'">'."\n";
$html .= "\n" . '<ul class="' . $class . '">' . "\n";
$open++;
}
$level = $item['level'];
} elseif ($item['level'] < $level) {
//close last item
$html .= '</li>'."\n";
$html .= '</li>' . "\n";
while ($level > $item['level'] && $open > 0) {
//close higher lists
$html .= '</ul>'."\n".'</li>'."\n";
$html .= '</ul>' . "\n" . '</li>' . "\n";
$level--;
$open--;
}
} elseif ($html !== '') {
//close previous item
$html .= '</li>'."\n";
$html .= '</li>' . "\n";
}
//print item
@ -500,15 +500,15 @@ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = fa
}
//close remaining items and lists
$html .= '</li>'."\n";
$html .= '</li>' . "\n";
while ($open-- > 0) {
$html .= '</ul></li>'."\n";
$html .= '</ul></li>' . "\n";
}
if ($forcewrapper || $start_level < 2) {
// Trigger building a wrapper ul if the first level is
// 0 (we have a root object) or 1 (just the root content)
$html = "\n".'<ul class="'.$class.'">'."\n".$html.'</ul>'."\n";
$html = "\n" . '<ul class="' . $class . '">' . "\n" . $html . '</ul>' . "\n";
}
return $html;
@ -523,7 +523,7 @@ function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = fa
*/
function html_backlinks()
{
dbg_deprecated(Backlinks::class .'::show()');
dbg_deprecated(Backlinks::class . '::show()');
(new Backlinks())->show();
}
@ -540,7 +540,7 @@ function html_backlinks()
*/
function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false)
{
dbg_deprecated('see '. PageDiff::class .'::buildDiffHead()');
dbg_deprecated('see ' . PageDiff::class . '::buildDiffHead()');
return ['', '', '', ''];
}
@ -557,7 +557,7 @@ function html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = fa
*/
function html_diff($text = '', $intro = true, $type = null)
{
dbg_deprecated(PageDiff::class .'::show()');
dbg_deprecated(PageDiff::class . '::show()');
global $INFO;
(new PageDiff($INFO['id']))->compareWith($text)->preference([
'showIntro' => $intro,
@ -577,7 +577,7 @@ function html_diff($text = '', $intro = true, $type = null)
*/
function html_diff_navigation($pagelog, $type, $l_rev, $r_rev)
{
dbg_deprecated('see '. PageDiff::class .'::buildRevisionsNavigation()');
dbg_deprecated('see ' . PageDiff::class . '::buildRevisionsNavigation()');
return ['', ''];
}
@ -593,7 +593,7 @@ function html_diff_navigation($pagelog, $type, $l_rev, $r_rev)
*/
function html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null)
{
dbg_deprecated('see '. PageDiff::class .'::diffViewlink()');
dbg_deprecated('see ' . PageDiff::class . '::diffViewlink()');
return '';
}
@ -606,7 +606,7 @@ function html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null)
*/
function html_insert_softbreaks($diffhtml)
{
dbg_deprecated(PageDiff::class .'::insertSoftbreaks()');
dbg_deprecated(PageDiff::class . '::insertSoftbreaks()');
return (new PageDiff())->insertSoftbreaks($diffhtml);
}
@ -621,7 +621,7 @@ function html_insert_softbreaks($diffhtml)
*/
function html_conflict($text, $summary)
{
dbg_deprecated(PageConflict::class .'::show()');
dbg_deprecated(PageConflict::class . '::show()');
(new PageConflict($text, $summary))->show();
}
@ -644,7 +644,7 @@ function html_msgarea()
$hash = md5($msg['msg']);
if (isset($shown[$hash])) continue; // skip double messages
if (info_msg_allowed($msg)) {
echo '<div class="'.$msg['lvl'].'">';
echo '<div class="' . $msg['lvl'] . '">';
echo $msg['msg'];
echo '</div>';
}
@ -662,7 +662,7 @@ function html_msgarea()
*/
function html_register()
{
dbg_deprecated(UserRegister::class .'::show()');
dbg_deprecated(UserRegister::class . '::show()');
(new UserRegister())->show();
}
@ -675,7 +675,7 @@ function html_register()
*/
function html_updateprofile()
{
dbg_deprecated(UserProfile::class .'::show()');
dbg_deprecated(UserProfile::class . '::show()');
(new UserProfile())->show();
}
@ -688,7 +688,7 @@ function html_updateprofile()
*/
function html_edit()
{
dbg_deprecated(Editor::class .'::show()');
dbg_deprecated(Editor::class . '::show()');
(new Editor())->show();
}
@ -702,7 +702,7 @@ function html_edit()
*/
function html_edit_form($param)
{
dbg_deprecated(Editor::class .'::addTextarea()');
dbg_deprecated(Editor::class . '::addTextarea()');
(new Editor())->addTextarea($param);
}
@ -754,7 +754,7 @@ function html_debug()
echo '</pre>';
echo '<b>rel DOKU_BASE:</b><pre>';
echo dirname($_SERVER['PHP_SELF']).'/';
echo dirname($_SERVER['PHP_SELF']) . '/';
echo '</pre>';
echo '<b>PHP Version:</b><pre>';
@ -772,7 +772,7 @@ function html_debug()
if ($auth) {
echo '<b>Auth backend capabilities:</b><pre>';
foreach ($auth->getCapabilities() as $cando) {
echo ' '.str_pad($cando, 16) .' => '. (int)$auth->canDo($cando) . DOKU_LF;
echo ' ' . str_pad($cando, 16) . ' => ' . (int)$auth->canDo($cando) . DOKU_LF;
}
echo '</pre>';
}
@ -814,7 +814,7 @@ function html_debug()
*/
function html_resendpwd()
{
dbg_deprecated(UserResendPwd::class .'::show()');
dbg_deprecated(UserResendPwd::class . '::show()');
(new UserResendPwd())->show();
}
@ -830,15 +830,15 @@ function html_TOC($toc)
{
if ($toc === []) return '';
global $lang;
$out = '<!-- TOC START -->'.DOKU_LF;
$out .= '<div id="dw__toc" class="dw__toc">'.DOKU_LF;
$out = '<!-- TOC START -->' . DOKU_LF;
$out .= '<div id="dw__toc" class="dw__toc">' . DOKU_LF;
$out .= '<h3 class="toggle">';
$out .= $lang['toc'];
$out .= '</h3>'.DOKU_LF;
$out .= '<div>'.DOKU_LF;
$out .= '</h3>' . DOKU_LF;
$out .= '<div>' . DOKU_LF;
$out .= html_buildlist($toc, 'toc', 'html_list_toc', null, true);
$out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
$out .= '<!-- TOC END -->'.DOKU_LF;
$out .= '</div>' . DOKU_LF . '</div>' . DOKU_LF;
$out .= '<!-- TOC END -->' . DOKU_LF;
return $out;
}
@ -851,12 +851,12 @@ function html_TOC($toc)
function html_list_toc($item)
{
if (isset($item['hid'])) {
$link = '#'.$item['hid'];
$link = '#' . $item['hid'];
} else {
$link = $item['link'];
}
return '<a href="'.$link.'">'.hsc($item['title']).'</a>';
return '<a href="' . $link . '">' . hsc($item['title']) . '</a>';
}
/**
@ -873,7 +873,7 @@ function html_list_toc($item)
function html_mktocitem($link, $text, $level, $hash = '#')
{
return [
'link' => $hash.$link,
'link' => $hash . $link,
'title' => $text,
'type' => 'ul',
'level' => $level
@ -896,7 +896,7 @@ function html_form($name, $form)
dbg_deprecated('use dokuwiki\Form\Form instead of Doku_Form');
// Safety check in case the caller forgets.
$form->endFieldset();
Event::createAndTrigger('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false);
Event::createAndTrigger('HTML_' . strtoupper($name) . 'FORM_OUTPUT', $form, 'html_form_output', false);
}
/**
@ -959,34 +959,34 @@ function html_flashobject($swf, $width, $height, $params = null, $flashvars = nu
$ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
// open object (with conditional comments)
$out .= '<!--[if !IE]> -->'.NL;
$out .= '<object '.buildAttributes($std).'>'.NL;
$out .= '<!-- <![endif]-->'.NL;
$out .= '<!--[if IE]>'.NL;
$out .= '<object '.buildAttributes($ie).'>'.NL;
$out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL;
$out .= '<!--><!-- -->'.NL;
$out .= '<!--[if !IE]> -->' . NL;
$out .= '<object ' . buildAttributes($std) . '>' . NL;
$out .= '<!-- <![endif]-->' . NL;
$out .= '<!--[if IE]>' . NL;
$out .= '<object ' . buildAttributes($ie) . '>' . NL;
$out .= ' <param name="movie" value="' . hsc($swf) . '" />' . NL;
$out .= '<!--><!-- -->' . NL;
// print params
if (is_array($params)) foreach ($params as $key => $val) {
$out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL;
$out .= ' <param name="' . hsc($key) . '" value="' . hsc($val) . '" />' . NL;
}
// add flashvars
if (is_array($flashvars)) {
$out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL;
$out .= ' <param name="FlashVars" value="' . buildURLparams($flashvars) . '" />' . NL;
}
// alternative content
if ($alt) {
$out .= $alt.NL;
$out .= $alt . NL;
} else {
$out .= $lang['noflash'].NL;
$out .= $lang['noflash'] . NL;
}
// finish
$out .= '</object>'.NL;
$out .= '<!-- <![endif]-->'.NL;
$out .= '</object>' . NL;
$out .= '<!-- <![endif]-->' . NL;
return $out;
}
@ -1000,13 +1000,13 @@ function html_flashobject($swf, $width, $height, $params = null, $flashvars = nu
*/
function html_tabs($tabs, $current_tab = null)
{
echo '<ul class="tabs">'.NL;
echo '<ul class="tabs">' . NL;
foreach ($tabs as $id => $tab) {
html_tab($tab['href'], $tab['caption'], $id === $current_tab);
}
echo '</ul>'.NL;
echo '</ul>' . NL;
}
/**
@ -1031,7 +1031,7 @@ function html_tab($href, $caption, $selected = false)
}
$tab .= hsc($caption)
. '</' . ($selected ? 'strong' : 'a') . '>'
. '</li>'.NL;
. '</li>' . NL;
echo $tab;
}
@ -1057,7 +1057,7 @@ function html_sizechange($sizechange, $form = null)
$value = '±' . $value;
}
if (!isset($form)) {
return '<span class="'.$class.'">'.$value.'</span>';
return '<span class="' . $class . '">' . $value . '</span>';
} else { // Doku_Form
$form->addElement(form_makeOpenTag('span', ['class' => $class]));
$form->addElement($value);

View File

@ -37,12 +37,12 @@ function idx_get_version()
$version = INDEXER_VERSION;
// DokuWiki version is included for the convenience of plugins
$data = ['dokuwiki'=>$version];
$data = ['dokuwiki' => $version];
Event::createAndTrigger('INDEXER_VERSION_GET', $data, null, false);
unset($data['dokuwiki']); // this needs to be first
ksort($data);
foreach ($data as $plugin => $vers)
$version .= '+'.$plugin.'='.$vers;
$version .= '+' . $plugin . '=' . $vers;
$indexer_version = $version;
}
return $indexer_version;
@ -97,7 +97,7 @@ function & idx_get_stopwords()
static $stopwords = null;
if (is_null($stopwords)) {
global $conf;
$swfile = DOKU_INC.'inc/lang/'.$conf['lang'].'/stopwords.txt';
$swfile = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/stopwords.txt';
if (file_exists($swfile)) {
$stopwords = file($swfile, FILE_IGNORE_NEW_LINES);
} else {
@ -125,13 +125,13 @@ function idx_addPage($page, $verbose = false, $force = false)
// check if page was deleted but is still in the index
if (!page_exists($page)) {
if (!file_exists($idxtag)) {
if ($verbose) echo "Indexer: $page does not exist, ignoring".DOKU_LF;
if ($verbose) echo "Indexer: $page does not exist, ignoring" . DOKU_LF;
return false;
}
$Indexer = idx_get_indexer();
$result = $Indexer->deletePage($page);
if ($result === "locked") {
if ($verbose) echo "Indexer: locked".DOKU_LF;
if ($verbose) echo "Indexer: locked" . DOKU_LF;
return false;
}
@unlink($idxtag);
@ -143,7 +143,7 @@ function idx_addPage($page, $verbose = false, $force = false)
if (trim(io_readFile($idxtag)) == idx_get_version()) {
$last = @filemtime($idxtag);
if ($last > @filemtime(wikiFN($page))) {
if ($verbose) echo "Indexer: index for $page up to date".DOKU_LF;
if ($verbose) echo "Indexer: index for $page up to date" . DOKU_LF;
return false;
}
}
@ -156,19 +156,19 @@ function idx_addPage($page, $verbose = false, $force = false)
$Indexer = idx_get_indexer();
$result = $Indexer->deletePage($page);
if ($result === "locked") {
if ($verbose) echo "Indexer: locked".DOKU_LF;
if ($verbose) echo "Indexer: locked" . DOKU_LF;
return false;
}
@unlink($idxtag);
}
if ($verbose) echo "Indexer: index disabled for $page".DOKU_LF;
if ($verbose) echo "Indexer: index disabled for $page" . DOKU_LF;
return $result;
}
$Indexer = idx_get_indexer();
$pid = $Indexer->getPID($page);
if ($pid === false) {
if ($verbose) echo "Indexer: getting the PID failed for $page".DOKU_LF;
if ($verbose) echo "Indexer: getting the PID failed for $page" . DOKU_LF;
return false;
}
$body = '';
@ -191,14 +191,14 @@ function idx_addPage($page, $verbose = false, $force = false)
$result = $Indexer->addPageWords($page, $body);
if ($result === "locked") {
if ($verbose) echo "Indexer: locked".DOKU_LF;
if ($verbose) echo "Indexer: locked" . DOKU_LF;
return false;
}
if ($result) {
$result = $Indexer->addMetaKeys($page, $metadata);
if ($result === "locked") {
if ($verbose) echo "Indexer: locked".DOKU_LF;
if ($verbose) echo "Indexer: locked" . DOKU_LF;
return false;
}
}
@ -206,7 +206,7 @@ function idx_addPage($page, $verbose = false, $force = false)
if ($result)
io_saveFile(metaFN($page, '.indexed'), idx_get_version());
if ($verbose) {
echo "Indexer: finished".DOKU_LF;
echo "Indexer: finished" . DOKU_LF;
return true;
}
return $result;
@ -258,7 +258,7 @@ function idx_tokenizer($string, $wc = false)
function idx_getIndex($idx, $suffix)
{
global $conf;
$fn = $conf['indexdir'].'/'.$idx.$suffix.'.idx';
$fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx';
if (!file_exists($fn)) return [];
return file($fn);
}
@ -282,11 +282,11 @@ function idx_listIndexLengths()
} else {
clearstatcache();
if (
file_exists($conf['indexdir'].'/lengths.idx')
&& (time() < @filemtime($conf['indexdir'].'/lengths.idx') + $conf['readdircache'])
file_exists($conf['indexdir'] . '/lengths.idx')
&& (time() < @filemtime($conf['indexdir'] . '/lengths.idx') + $conf['readdircache'])
) {
if (
($lengths = @file($conf['indexdir'].'/lengths.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))
($lengths = @file($conf['indexdir'] . '/lengths.idx', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES))
!== false
) {
$idx = [];
@ -315,7 +315,7 @@ function idx_listIndexLengths()
sort($idx);
// save this in a file
if ($docache) {
$handle = @fopen($conf['indexdir'].'/lengths.idx', 'w');
$handle = @fopen($conf['indexdir'] . '/lengths.idx', 'w');
@fwrite($handle, implode("\n", $idx));
@fclose($handle);
}
@ -342,9 +342,9 @@ function idx_indexLengths($filter)
$idx = [];
if (is_array($filter)) {
// testing if index files exist only
$path = $conf['indexdir']."/i";
$path = $conf['indexdir'] . "/i";
foreach (array_keys($filter) as $key) {
if (file_exists($path.$key.'.idx'))
if (file_exists($path . $key . '.idx'))
$idx[] = $key;
}
} else {

View File

@ -37,12 +37,18 @@ function checkUpdateMessages()
$is_http = substr(DOKU_MESSAGEURL, 0, 5) != 'https';
// check if new messages needs to be fetched
if ($lm < time()-(60*60*24) || $lm < @filemtime(DOKU_INC.DOKU_SCRIPT)) {
if ($lm < time() - (60 * 60 * 24) || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
@touch($cf);
Logger::debug("checkUpdateMessages(): downloading messages to ".$cf.($is_http?' (without SSL)':' (with SSL)'));
Logger::debug(
sprintf(
'checkUpdateMessages(): downloading messages to %s%s',
$cf,
$is_http ? ' (without SSL)' : ' (with SSL)'
)
);
$http = new DokuHTTPClient();
$http->timeout = 12;
$resp = $http->get(DOKU_MESSAGEURL.$updateVersion);
$resp = $http->get(DOKU_MESSAGEURL . $updateVersion);
if (is_string($resp) && ($resp == "" || substr(trim($resp), -1) == '%')) {
// basic sanity check that this is either an empty string response (ie "no messages")
// or it looks like one of our messages, not WiFi login or other interposed response
@ -72,11 +78,11 @@ function getVersionData()
{
$version = [];
//import version string
if (file_exists(DOKU_INC.'VERSION')) {
if (file_exists(DOKU_INC . 'VERSION')) {
//official release
$version['date'] = trim(io_readFile(DOKU_INC.'VERSION'));
$version['date'] = trim(io_readFile(DOKU_INC . 'VERSION'));
$version['type'] = 'Release';
} elseif (is_dir(DOKU_INC.'.git')) {
} elseif (is_dir(DOKU_INC . '.git')) {
$version['type'] = 'Git';
$version['date'] = 'unknown';
@ -128,7 +134,7 @@ function getVersionData()
}
} else {
global $updateVersion;
$version['date'] = 'update version '.$updateVersion;
$version['date'] = 'update version ' . $updateVersion;
$version['type'] = 'snapshot?';
}
return $version;
@ -159,11 +165,11 @@ function check()
global $INPUT;
if ($INFO['isadmin'] || $INFO['ismanager']) {
msg('DokuWiki version: '.getVersion(), 1);
msg('DokuWiki version: ' . getVersion(), 1);
if (version_compare(phpversion(), '7.4.0', '<')) {
msg('Your PHP version is too old ('.phpversion().' vs. 7.4+ needed)', -1);
msg('Your PHP version is too old (' . phpversion() . ' vs. 7.4+ needed)', -1);
} else {
msg('PHP version '.phpversion(), 1);
msg('PHP version ' . phpversion(), 1);
}
} elseif (version_compare(phpversion(), '7.4.0', '<')) {
msg('Your PHP version is too old', -1);
@ -197,11 +203,11 @@ function check()
msg('Old changelog exists', 0);
}
if (file_exists($conf['changelog'].'_failed')) {
if (file_exists($conf['changelog'] . '_failed')) {
msg('Importing old changelog failed', -1);
} elseif (file_exists($conf['changelog'].'_importing')) {
} elseif (file_exists($conf['changelog'] . '_importing')) {
msg('Importing old changelog now.', 0);
} elseif (file_exists($conf['changelog'].'_import_ok')) {
} elseif (file_exists($conf['changelog'] . '_import_ok')) {
msg('Old changelog imported', 1);
if (!plugin_isdisabled('importoldchangelog')) {
msg('Importoldchangelog plugin not disabled after import', -1);
@ -247,10 +253,10 @@ function check()
if (!$loc) {
msg('No valid locale is set for your PHP setup. You should fix this', -1);
} elseif (stripos($loc, 'utf') === false) {
msg('Your locale <code>'.hsc($loc).'</code> seems not to be a UTF-8 locale,
msg('Your locale <code>' . hsc($loc) . '</code> seems not to be a UTF-8 locale,
you should fix this if you encounter problems.', 0);
} else {
msg('Valid locale '.hsc($loc).' found.', 1);
msg('Valid locale ' . hsc($loc) . ' found.', 1);
}
if ($conf['allowdebug']) {
@ -260,13 +266,17 @@ function check()
}
if (!empty($INFO['userinfo']['name'])) {
msg('You are currently logged in as '.$INPUT->server->str('REMOTE_USER').' ('.$INFO['userinfo']['name'].')', 0);
msg('You are part of the groups '.implode(', ', $INFO['userinfo']['grps']), 0);
msg(sprintf(
"You are currently logged in as %s (%s)",
$INPUT->server->str('REMOTE_USER'),
$INFO['userinfo']['name']
), 0);
msg('You are part of the groups ' . implode(', ', $INFO['userinfo']['grps']), 0);
} else {
msg('You are currently not logged in', 0);
}
msg('Your current permission for this page is '.$INFO['perm'], 0);
msg('Your current permission for this page is ' . $INFO['perm'], 0);
if (file_exists($INFO['filepath']) && is_writable($INFO['filepath'])) {
msg('The current page is writable by the webserver', 1);
@ -293,7 +303,7 @@ function check()
}
foreach (idx_getIndex('metadata', '') as $index) {
if (count(idx_getIndex($index.'_w', '')) !== count(idx_getIndex($index.'_i', ''))) {
if (count(idx_getIndex($index . '_w', '')) !== count(idx_getIndex($index . '_i', ''))) {
$index_corrupted = true;
break;
}
@ -377,7 +387,7 @@ function msg($message, $lvl = 0, $line = '', $file = '', $allow = MSG_PUBLIC)
/* Show msg normally - event could suppress message show */
if ($msgdata['line'] || $msgdata['file']) {
$basename = PhpString::basename($msgdata['file']);
$msgdata['msg'] .=' ['.$basename.':'.$msgdata['line'].']';
$msgdata['msg'] .= ' [' . $basename . ':' . $msgdata['line'] . ']';
}
if (!isset($MSG)) $MSG = [];
@ -386,7 +396,7 @@ function msg($message, $lvl = 0, $line = '', $file = '', $allow = MSG_PUBLIC)
if (function_exists('html_msgarea')) {
html_msgarea();
} else {
echo "ERROR(".$msgdata['lvl'].") ".$msgdata['msg']."\n";
echo "ERROR(" . $msgdata['lvl'] . ") " . $msgdata['msg'] . "\n";
}
unset($GLOBALS['MSG']);
}
@ -427,7 +437,7 @@ function info_msg_allowed($msg)
default:
trigger_error(
'invalid msg allow restriction. msg="'.$msg['msg'].'" allow='.$msg['allow'].'"',
'invalid msg allow restriction. msg="' . $msg['msg'] . '" allow=' . $msg['allow'] . '"',
E_USER_WARNING
);
return $INFO['isadmin'];
@ -517,13 +527,13 @@ function dbg_backtrace()
if (isset($call['args'])) {
foreach ($call['args'] as $arg) {
if (is_object($arg)) {
$params[] = '[Object '.get_class($arg).']';
$params[] = '[Object ' . get_class($arg) . ']';
} elseif (is_array($arg)) {
$params[] = '[Array]';
} elseif (is_null($arg)) {
$params[] = '[NULL]';
} else {
$params[] = '"'.$arg.'"';
$params[] = '"' . $arg . '"';
}
}
}

View File

@ -17,7 +17,7 @@ use dokuwiki\Extension\EventHandler;
*/
function delta_time($start = 0)
{
return microtime(true)-((float)$start);
return microtime(true) - ((float)$start);
}
define('DOKU_START_TIME', delta_time());
@ -25,20 +25,20 @@ global $config_cascade;
$config_cascade = [];
// if available load a preload config file
$preload = fullpath(__DIR__).'/preload.php';
$preload = fullpath(__DIR__) . '/preload.php';
if (file_exists($preload)) include($preload);
// define the include path
if (!defined('DOKU_INC')) define('DOKU_INC', fullpath(__DIR__.'/../').'/');
if (!defined('DOKU_INC')) define('DOKU_INC', fullpath(__DIR__ . '/../') . '/');
// define Plugin dir
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
// define config path (packagers may want to change this to /etc/dokuwiki/)
if (!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC.'conf/');
if (!defined('DOKU_CONF')) define('DOKU_CONF', DOKU_INC . 'conf/');
// check for error reporting override or set error reporting to sane values
if (!defined('DOKU_E_LEVEL') && file_exists(DOKU_CONF.'report_e_all')) {
if (!defined('DOKU_E_LEVEL') && file_exists(DOKU_CONF . 'report_e_all')) {
define('DOKU_E_LEVEL', E_ALL);
}
if (!defined('DOKU_E_LEVEL')) {
@ -64,7 +64,7 @@ global $cache_metadata;
// always include 'inc/config_cascade.php'
// previously in preload.php set fields of $config_cascade will be merged with the defaults
include(DOKU_INC.'inc/config_cascade.php');
include(DOKU_INC . 'inc/config_cascade.php');
//prepare config array()
global $conf;
@ -128,7 +128,7 @@ if (!defined('DOKU_TPL')) {
* @deprecated 2012-10-13 replaced by more dynamic method
* @see tpl_basedir()
*/
define('DOKU_TPL', DOKU_BASE.'lib/tpl/'.$conf['template'].'/');
define('DOKU_TPL', DOKU_BASE . 'lib/tpl/' . $conf['template'] . '/');
}
if (!defined('DOKU_TPLINC')) {
@ -136,7 +136,7 @@ if (!defined('DOKU_TPLINC')) {
* @deprecated 2012-10-13 replaced by more dynamic method
* @see tpl_incdir()
*/
define('DOKU_TPLINC', DOKU_INC.'lib/tpl/'.$conf['template'].'/');
define('DOKU_TPLINC', DOKU_INC . 'lib/tpl/' . $conf['template'] . '/');
}
// make session rewrites XHTML compliant
@ -201,8 +201,8 @@ global $plugin_controller_class, $plugin_controller;
if (empty($plugin_controller_class)) $plugin_controller_class = PluginController::class;
// load libraries
require_once(DOKU_INC.'vendor/autoload.php');
require_once(DOKU_INC.'inc/load.php');
require_once(DOKU_INC . 'vendor/autoload.php');
require_once(DOKU_INC . 'inc/load.php');
// from now on everything is an exception
ErrorHandler::register();
@ -295,7 +295,7 @@ function init_paths()
];
foreach ($paths as $c => $p) {
$path = empty($conf[$c]) ? $conf['savedir'].'/'.$p : $conf[$c];
$path = empty($conf[$c]) ? $conf['savedir'] . '/' . $p : $conf[$c];
$conf[$c] = init_path($path);
if (empty($conf[$c])) {
$path = fullpath($path);
@ -310,11 +310,11 @@ function init_paths()
$conf['changelog_old'] = init_path(
$conf['changelog'] ?? $conf['savedir'] . '/changes.log'
);
if ($conf['changelog_old']=='') {
if ($conf['changelog_old'] == '') {
unset($conf['changelog_old']); }
// hardcoded changelog because it is now a cache that lives in meta
$conf['changelog'] = $conf['metadir'].'/_dokuwiki.changes';
$conf['media_changelog'] = $conf['metadir'].'/_media.changes';
$conf['changelog'] = $conf['metadir'] . '/_dokuwiki.changes';
$conf['media_changelog'] = $conf['metadir'] . '/_media.changes';
}
/**
@ -329,7 +329,7 @@ function init_lang($langCode)
$lang = [];
//load the language files
require(DOKU_INC.'inc/lang/en/lang.php');
require(DOKU_INC . 'inc/lang/en/lang.php');
foreach ($config_cascade['lang']['core'] as $config_file) {
if (file_exists($config_file . 'en/lang.php')) {
include($config_file . 'en/lang.php');
@ -337,8 +337,8 @@ function init_lang($langCode)
}
if ($langCode && $langCode != 'en') {
if (file_exists(DOKU_INC."inc/lang/$langCode/lang.php")) {
require(DOKU_INC."inc/lang/$langCode/lang.php");
if (file_exists(DOKU_INC . "inc/lang/$langCode/lang.php")) {
require(DOKU_INC . "inc/lang/$langCode/lang.php");
}
foreach ($config_cascade['lang']['core'] as $config_file) {
if (file_exists($config_file . "$langCode/lang.php")) {
@ -355,7 +355,7 @@ function init_files()
{
global $conf;
$files = [$conf['indexdir'].'/page.idx'];
$files = [$conf['indexdir'] . '/page.idx'];
foreach ($files as $file) {
if (!file_exists($file)) {
@ -387,7 +387,7 @@ function init_path($path)
// check existence
$p = fullpath($path);
if (!file_exists($p)) {
$p = fullpath(DOKU_INC.$path);
$p = fullpath(DOKU_INC . $path);
if (!file_exists($p)) {
return '';
}
@ -467,11 +467,11 @@ function getBaseURL($abs = null)
$dir = dirname($_SERVER['PHP_SELF']);
} elseif ($_SERVER['DOCUMENT_ROOT'] && $_SERVER['SCRIPT_FILENAME']) {
$dir = preg_replace(
'/^'.preg_quote($_SERVER['DOCUMENT_ROOT'], '/').'/',
'/^' . preg_quote($_SERVER['DOCUMENT_ROOT'], '/') . '/',
'',
$_SERVER['SCRIPT_FILENAME']
);
$dir = dirname('/'.$dir);
$dir = dirname('/' . $dir);
} else {
$dir = '.'; //probably wrong
}
@ -489,15 +489,15 @@ function getBaseURL($abs = null)
if (!$abs) return $dir;
//use config if available, trim any slash from end of baseurl to avoid multiple consecutive slashes in the path
if (!empty($conf['baseurl'])) return rtrim($conf['baseurl'], '/').$dir;
if (!empty($conf['baseurl'])) return rtrim($conf['baseurl'], '/') . $dir;
//split hostheader into host and port
if (isset($_SERVER['HTTP_HOST'])) {
$parsed_host = parse_url('http://'.$_SERVER['HTTP_HOST']);
$parsed_host = parse_url('http://' . $_SERVER['HTTP_HOST']);
$host = $parsed_host['host'] ?? null;
$port = $parsed_host['port'] ?? null;
} elseif (isset($_SERVER['SERVER_NAME'])) {
$parsed_host = parse_url('http://'.$_SERVER['SERVER_NAME']);
$parsed_host = parse_url('http://' . $_SERVER['SERVER_NAME']);
$host = $parsed_host['host'] ?? null;
$port = $parsed_host['port'] ?? null;
} else {
@ -521,9 +521,9 @@ function getBaseURL($abs = null)
}
}
if ($port !== '') $port = ':'.$port;
if ($port !== '') $port = ':' . $port;
return $proto.$host.$port.$dir;
return $proto . $host . $port . $dir;
}
/**
@ -584,7 +584,7 @@ function nice_die($msg)
</html>
EOT;
if (defined('DOKU_UNITTEST')) {
throw new RuntimeException('nice_die: '.$msg);
throw new RuntimeException('nice_die: ' . $msg);
}
exit(1);
}
@ -616,7 +616,7 @@ function fullpath($path, $exists = false)
} elseif ($iswin) {
// match drive letter and UNC paths
if (preg_match('!^([a-zA-z]:)(.*)!', $path, $match)) {
$root = $match[1].'/';
$root = $match[1] . '/';
$path = $match[2];
} elseif (preg_match('!^(\\\\\\\\[^\\\\/]+\\\\[^\\\\/]+[\\\\/])(.*)!', $path, $match)) {
$root = $match[1];
@ -628,7 +628,7 @@ function fullpath($path, $exists = false)
// if the given path wasn't absolute already, prepend the script path and retry
if (!$root) {
$base = dirname($_SERVER['SCRIPT_FILENAME']);
$path = $base.'/'.$path;
$path = $base . '/' . $path;
if ($run == 0) { // avoid endless recursion when base isn't absolute for some reason
$run++;
return fullpath($path, $exists);
@ -637,17 +637,17 @@ function fullpath($path, $exists = false)
$run = 0;
// canonicalize
$path=explode('/', $path);
$newpath=[];
$path = explode('/', $path);
$newpath = [];
foreach ($path as $p) {
if ($p === '' || $p === '.') continue;
if ($p==='..') {
if ($p === '..') {
array_pop($newpath);
continue;
}
$newpath[] = $p;
}
$finalpath = $root.implode('/', $newpath);
$finalpath = $root . implode('/', $newpath);
// check for existence when needed (except when unit testing)
if ($exists && !defined('DOKU_UNITTEST') && !file_exists($finalpath)) {

View File

@ -27,18 +27,18 @@ use dokuwiki\Extension\Event;
function io_sweepNS($id, $basedir = 'datadir')
{
global $conf;
$types = ['datadir'=>'pages', 'mediadir'=>'media'];
$types = ['datadir' => 'pages', 'mediadir' => 'media'];
$ns_type = ($types[$basedir] ?? false);
$delone = false;
//scan all namespaces
while (($id = getNS($id)) !== false) {
$dir = $conf[$basedir].'/'.utf8_encodeFN(str_replace(':', '/', $id));
$dir = $conf[$basedir] . '/' . utf8_encodeFN(str_replace(':', '/', $id));
//try to delete dir else return
if (@rmdir($dir)) {
if ($ns_type!==false) {
if ($ns_type !== false) {
$data = [$id, $ns_type];
$delone = true; // we deleted at least one dir
Event::createAndTrigger('IO_NAMESPACE_DELETED', $data);
@ -87,7 +87,7 @@ function io_readWikiPage($file, $id, $rev = false)
*/
function _io_readWikiPage_action($data)
{
if (is_array($data) && is_array($data[0]) && count($data[0])===2) {
if (is_array($data) && is_array($data[0]) && count($data[0]) === 2) {
return io_readFile(...$data[0]);
} else {
return ''; //callback error
@ -157,8 +157,8 @@ function bzfile($file, $array = false)
if ($array) {
$pos = strpos($str, "\n");
while ($pos !== false) {
$lines[] = substr($str, 0, $pos+1);
$str = substr($str, $pos+1);
$lines[] = substr($str, 0, $pos + 1);
$str = substr($str, $pos + 1);
$pos = strpos($str, "\n");
}
}
@ -197,7 +197,7 @@ function io_writeWikiPage($file, $content, $id, $rev = false)
{
if (empty($rev)) {
$rev = false; }
if ($rev===false) {
if ($rev === false) {
io_createNamespace($id); } // create namespaces as needed
$data = [[$file, $content, false], getNS($id), noNS($id), $rev];
return Event::createAndTrigger('IO_WIKIPAGE_WRITE', $data, '_io_writeWikiPage_action', false);
@ -212,7 +212,7 @@ function io_writeWikiPage($file, $content, $id, $rev = false)
*/
function _io_writeWikiPage_action($data)
{
if (is_array($data) && is_array($data[0]) && count($data[0])===3) {
if (is_array($data) && is_array($data[0]) && count($data[0]) === 3) {
$ok = io_saveFile(...$data[0]);
// for attic files make sure the file has the mtime of the revision
if ($ok && is_int($data[3]) && $data[3] > 0) {
@ -242,7 +242,7 @@ function _io_saveFile($file, $content, $append)
if (substr($file, -3) == '.gz') {
if (!DOKU_HAS_GZIP) return false;
$fh = @gzopen($file, $mode.'9');
$fh = @gzopen($file, $mode . '9');
if (!$fh) return false;
gzwrite($fh, $content);
gzclose($fh);
@ -251,7 +251,7 @@ function _io_saveFile($file, $content, $append)
if ($append) {
$bzcontent = bzfile($file);
if ($bzcontent === false) return false;
$content = $bzcontent.$content;
$content = $bzcontent . $content;
}
$fh = @bzopen($file, 'w');
if (!$fh) return false;
@ -346,7 +346,7 @@ function io_replaceInFile($file, $oldline, $newline, $regex = false, $maxlines =
}
// make non-regexes into regexes
$pattern = $regex ? $oldline : '/^'.preg_quote($oldline, '/').'$/';
$pattern = $regex ? $oldline : '/^' . preg_quote($oldline, '/') . '$/';
$replace = $regex ? $newline : addcslashes($newline, '\$');
// remove matching lines
@ -416,7 +416,7 @@ function io_lock($file)
{
global $conf;
$lockDir = $conf['lockdir'].'/'.md5($file);
$lockDir = $conf['lockdir'] . '/' . md5($file);
@ignore_user_abort(1);
$timeStart = time();
@ -443,7 +443,7 @@ function io_unlock($file)
{
global $conf;
$lockDir = $conf['lockdir'].'/'.md5($file);
$lockDir = $conf['lockdir'] . '/' . md5($file);
@rmdir($lockDir);
@ignore_user_abort(0);
}
@ -464,7 +464,7 @@ function io_unlock($file)
function io_createNamespace($id, $ns_type = 'pages')
{
// verify ns_type
$types = ['pages'=>'wikiFN', 'media'=>'mediaFN'];
$types = ['pages' => 'wikiFN', 'media' => 'mediaFN'];
if (!isset($types[$ns_type])) {
trigger_error('Bad $ns_type parameter for io_createNamespace().');
return;
@ -477,7 +477,7 @@ function io_createNamespace($id, $ns_type = 'pages')
while (!@is_dir($tmp) && !(file_exists($tmp) && !is_dir($tmp))) {
array_pop($ns_stack);
$ns = implode(':', $ns_stack);
if (strlen($ns)==0) {
if (strlen($ns) == 0) {
break; }
$missing[] = $ns;
$tmp = dirname(call_user_func($types[$ns_type], $ns));
@ -520,7 +520,7 @@ function io_makeFileDir($file)
function io_mkdir_p($target)
{
global $conf;
if (@is_dir($target)||empty($target)) return 1; // best case check first
if (@is_dir($target) || empty($target)) return 1; // best case check first
if (file_exists($target) && !is_dir($target)) return 0;
//recursion
if (io_mkdir_p(substr($target, 0, strrpos($target, '/')))) {
@ -591,7 +591,7 @@ function io_mktmpdir()
$base = $conf['tmpdir'];
$dir = md5(uniqid(random_int(0, mt_getrandmax()), true));
$tmpdir = $base.'/'.$dir;
$tmpdir = $base . '/' . $dir;
if (io_mkdir_p($tmpdir)) {
return($tmpdir);
@ -637,7 +637,7 @@ function io_download($url, $file, $useAttachment = false, $defaultName = '', $ma
if ($useAttachment) {
if (isset($http->resp_headers['content-disposition'])) {
$content_disposition = $http->resp_headers['content-disposition'];
$match=[];
$match = [];
if (
is_string($content_disposition) &&
preg_match('/attachment;\s*filename\s*=\s*"([^"]*)"/i', $content_disposition, $match)
@ -702,9 +702,9 @@ function io_rename($from, $to)
function io_exec($cmd, $input, &$output)
{
$descspec = [
0=>["pipe", "r"],
1=>["pipe", "w"],
2=>["pipe", "w"]
0 => ["pipe", "r"],
1 => ["pipe", "w"],
2 => ["pipe", "w"]
];
$ph = proc_open($cmd, $descspec, $pipes);
if (!$ph) return -1;

View File

@ -12,31 +12,31 @@ spl_autoload_register('load_autoload');
// require all the common libraries
// for a few of these order does matter
require_once(DOKU_INC.'inc/defines.php');
require_once(DOKU_INC.'inc/actions.php');
require_once(DOKU_INC.'inc/changelog.php');
require_once(DOKU_INC.'inc/common.php');
require_once(DOKU_INC.'inc/confutils.php');
require_once(DOKU_INC.'inc/pluginutils.php');
require_once(DOKU_INC.'inc/form.php');
require_once(DOKU_INC.'inc/fulltext.php');
require_once(DOKU_INC.'inc/html.php');
require_once(DOKU_INC.'inc/httputils.php');
require_once(DOKU_INC.'inc/indexer.php');
require_once(DOKU_INC.'inc/infoutils.php');
require_once(DOKU_INC.'inc/io.php');
require_once(DOKU_INC.'inc/mail.php');
require_once(DOKU_INC.'inc/media.php');
require_once(DOKU_INC.'inc/pageutils.php');
require_once(DOKU_INC.'inc/parserutils.php');
require_once(DOKU_INC.'inc/search.php');
require_once(DOKU_INC.'inc/template.php');
require_once(DOKU_INC.'inc/toolbar.php');
require_once(DOKU_INC.'inc/utf8.php');
require_once(DOKU_INC.'inc/auth.php');
require_once(DOKU_INC.'inc/compatibility.php');
require_once(DOKU_INC.'inc/deprecated.php');
require_once(DOKU_INC.'inc/legacy.php');
require_once(DOKU_INC . 'inc/defines.php');
require_once(DOKU_INC . 'inc/actions.php');
require_once(DOKU_INC . 'inc/changelog.php');
require_once(DOKU_INC . 'inc/common.php');
require_once(DOKU_INC . 'inc/confutils.php');
require_once(DOKU_INC . 'inc/pluginutils.php');
require_once(DOKU_INC . 'inc/form.php');
require_once(DOKU_INC . 'inc/fulltext.php');
require_once(DOKU_INC . 'inc/html.php');
require_once(DOKU_INC . 'inc/httputils.php');
require_once(DOKU_INC . 'inc/indexer.php');
require_once(DOKU_INC . 'inc/infoutils.php');
require_once(DOKU_INC . 'inc/io.php');
require_once(DOKU_INC . 'inc/mail.php');
require_once(DOKU_INC . 'inc/media.php');
require_once(DOKU_INC . 'inc/pageutils.php');
require_once(DOKU_INC . 'inc/parserutils.php');
require_once(DOKU_INC . 'inc/search.php');
require_once(DOKU_INC . 'inc/template.php');
require_once(DOKU_INC . 'inc/toolbar.php');
require_once(DOKU_INC . 'inc/utf8.php');
require_once(DOKU_INC . 'inc/auth.php');
require_once(DOKU_INC . 'inc/compatibility.php');
require_once(DOKU_INC . 'inc/deprecated.php');
require_once(DOKU_INC . 'inc/legacy.php');
/**
* spl_autoload_register callback
@ -55,25 +55,25 @@ function load_autoload($name)
{
static $classes = null;
if ($classes === null) $classes = [
'Diff' => DOKU_INC.'inc/DifferenceEngine.php',
'UnifiedDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
'TableDiffFormatter' => DOKU_INC.'inc/DifferenceEngine.php',
'cache' => DOKU_INC.'inc/cache.php',
'cache_parser' => DOKU_INC.'inc/cache.php',
'cache_instructions' => DOKU_INC.'inc/cache.php',
'cache_renderer' => DOKU_INC.'inc/cache.php',
'Input' => DOKU_INC.'inc/Input.class.php',
'JpegMeta' => DOKU_INC.'inc/JpegMeta.php',
'SimplePie' => DOKU_INC.'inc/SimplePie.php',
'FeedParser' => DOKU_INC.'inc/FeedParser.php',
'SafeFN' => DOKU_INC.'inc/SafeFN.class.php',
'Mailer' => DOKU_INC.'inc/Mailer.class.php',
'Doku_Handler' => DOKU_INC.'inc/parser/handler.php',
'Doku_Renderer' => DOKU_INC.'inc/parser/renderer.php',
'Doku_Renderer_xhtml' => DOKU_INC.'inc/parser/xhtml.php',
'Doku_Renderer_code' => DOKU_INC.'inc/parser/code.php',
'Doku_Renderer_xhtmlsummary' => DOKU_INC.'inc/parser/xhtmlsummary.php',
'Doku_Renderer_metadata' => DOKU_INC.'inc/parser/metadata.php'
'Diff' => DOKU_INC . 'inc/DifferenceEngine.php',
'UnifiedDiffFormatter' => DOKU_INC . 'inc/DifferenceEngine.php',
'TableDiffFormatter' => DOKU_INC . 'inc/DifferenceEngine.php',
'cache' => DOKU_INC . 'inc/cache.php',
'cache_parser' => DOKU_INC . 'inc/cache.php',
'cache_instructions' => DOKU_INC . 'inc/cache.php',
'cache_renderer' => DOKU_INC . 'inc/cache.php',
'Input' => DOKU_INC . 'inc/Input.class.php',
'JpegMeta' => DOKU_INC . 'inc/JpegMeta.php',
'SimplePie' => DOKU_INC . 'inc/SimplePie.php',
'FeedParser' => DOKU_INC . 'inc/FeedParser.php',
'SafeFN' => DOKU_INC . 'inc/SafeFN.class.php',
'Mailer' => DOKU_INC . 'inc/Mailer.class.php',
'Doku_Handler' => DOKU_INC . 'inc/parser/handler.php',
'Doku_Renderer' => DOKU_INC . 'inc/parser/renderer.php',
'Doku_Renderer_xhtml' => DOKU_INC . 'inc/parser/xhtml.php',
'Doku_Renderer_code' => DOKU_INC . 'inc/parser/code.php',
'Doku_Renderer_xhtmlsummary' => DOKU_INC . 'inc/parser/xhtmlsummary.php',
'Doku_Renderer_metadata' => DOKU_INC . 'inc/parser/metadata.php'
];
if (isset($classes[$name])) {
@ -119,7 +119,7 @@ function load_autoload($name)
// template namespace
if (substr($name, 0, 18) === 'dokuwiki/template/') {
$name = str_replace('/test/', '/_test/', $name); // no underscore in test namespace
$file = DOKU_INC.'lib/tpl/' . substr($name, 18) . '.php';
$file = DOKU_INC . 'lib/tpl/' . substr($name, 18) . '.php';
if (file_exists($file)) {
try {
require $file;

View File

@ -23,7 +23,7 @@
if (!defined('RFC2822_ATEXT')) define('RFC2822_ATEXT', "0-9a-zA-Z!#$%&'*+/=?^_`{|}~-");
if (!defined('PREG_PATTERN_VALID_EMAIL')) define(
'PREG_PATTERN_VALID_EMAIL',
'['.RFC2822_ATEXT.']+(?:\.['.RFC2822_ATEXT.']+)*@(?i:[0-9a-z][0-9a-z-]*\.)+(?i:[a-z]{2,63})'
'[' . RFC2822_ATEXT . ']+(?:\.[' . RFC2822_ATEXT . ']+)*@(?i:[0-9a-z][0-9a-z-]*\.)+(?i:[a-z]{2,63})'
);
/**
@ -44,7 +44,7 @@ function mail_setup()
// auto constructed address
$host = @parse_url(DOKU_URL, PHP_URL_HOST);
if (!$host) $host = 'example.com';
$noreply = 'noreply@'.$host;
$noreply = 'noreply@' . $host;
$replace = [];
if (!empty($USERINFO['mail'])) {
@ -104,10 +104,10 @@ function mail_isvalid($email)
function mail_quotedprintable_encode($sText, $maxlen = 74, $bEmulate_imap_8bit = true)
{
// split text into lines
$aLines= preg_split("/(?:\r\n|\r|\n)/", $sText);
$aLines = preg_split("/(?:\r\n|\r|\n)/", $sText);
$cnt = count($aLines);
for ($i=0; $i<$cnt; $i++) {
for ($i = 0; $i < $cnt; $i++) {
$sLine =& $aLines[$i];
if ($sLine === '') continue; // do nothing, if empty
@ -124,24 +124,24 @@ function mail_quotedprintable_encode($sText, $maxlen = 74, $bEmulate_imap_8bit =
// encode x09,x20 at lineends
{
$iLength = strlen($sLine);
$iLastChar = ord($sLine[$iLength-1]);
$iLastChar = ord($sLine[$iLength - 1]);
// !!!!!!!!
// imap_8_bit does not encode x20 at the very end of a text,
// here is, where I don't agree with imap_8_bit,
// please correct me, if I'm wrong,
// or comment next line for RFC2045 conformance, if you like
if (!($bEmulate_imap_8bit && ($i==count($aLines)-1))) {
if (($iLastChar==0x09)||($iLastChar==0x20)) {
$sLine[$iLength-1]='=';
$sLine .= ($iLastChar==0x09)?'09':'20';
if (!($bEmulate_imap_8bit && ($i == count($aLines) - 1))) {
if (($iLastChar == 0x09) || ($iLastChar == 0x20)) {
$sLine[$iLength - 1] = '=';
$sLine .= ($iLastChar == 0x09) ? '09' : '20';
}
}
} // imap_8bit encodes x20 before chr(13), too
// although IMHO not requested by RFC2045, why not do it safer :)
// and why not encode any x20 around chr(10) or chr(13)
if ($bEmulate_imap_8bit) {
$sLine=str_replace(' =0D', '=20=0D', $sLine);
$sLine = str_replace(' =0D', '=20=0D', $sLine);
//$sLine=str_replace(' =0A','=20=0A',$sLine);
//$sLine=str_replace('=0D ','=0D=20',$sLine);
//$sLine=str_replace('=0A ','=0A=20',$sLine);
@ -153,7 +153,7 @@ function mail_quotedprintable_encode($sText, $maxlen = 74, $bEmulate_imap_8bit =
// and after soft linebreaks, as well,
// but this wouldn't be caught by such an easy RegExp
if ($maxlen) {
preg_match_all('/.{1,'.($maxlen - 2).'}([^=]{0,2})?/', $sLine, $aMatch);
preg_match_all('/.{1,' . ($maxlen - 2) . '}([^=]{0,2})?/', $sLine, $aMatch);
$sLine = implode('=' . MAILHEADER_EOL, $aMatch[0]); // add soft crlf's
}
}

View File

@ -36,19 +36,19 @@ use splitbrain\slika\Slika;
function media_filesinuse($data, $id)
{
global $lang;
echo '<h1>'.$lang['reference'].' <code>'.hsc(noNS($id)).'</code></h1>';
echo '<p>'.hsc($lang['ref_inuse']).'</p>';
echo '<h1>' . $lang['reference'] . ' <code>' . hsc(noNS($id)) . '</code></h1>';
echo '<p>' . hsc($lang['ref_inuse']) . '</p>';
$hidden=0; //count of hits without read permission
$hidden = 0; //count of hits without read permission
foreach ($data as $row) {
if (auth_quickaclcheck($row) >= AUTH_READ && isVisiblePage($row)) {
echo '<div class="search_result">';
echo '<span class="mediaref_ref">'.hsc($row).'</span>';
echo '<span class="mediaref_ref">' . hsc($row) . '</span>';
echo '</div>';
} else $hidden++;
}
if ($hidden) {
echo '<div class="mediaref_hidden">'.$lang['ref_hidden'].'</div>';
echo '<div class="mediaref_hidden">' . $lang['ref_hidden'] . '</div>';
}
}
@ -75,7 +75,7 @@ function media_metasave($id, $auth, $data)
$meta->_parseAll();
foreach ($data as $key => $val) {
$val=trim($val);
$val = trim($val);
if (empty($val)) {
$meta->deleteField($key);
} else {
@ -133,7 +133,7 @@ function media_ispublic($id)
{
if (media_isexternal($id)) return true;
$id = cleanID($id);
if (auth_aclcheck(getNS($id).':*', '', []) >= AUTH_READ) return true;
if (auth_aclcheck(getNS($id) . ':*', '', []) >= AUTH_READ) return true;
return false;
}
@ -152,7 +152,7 @@ function media_metaform($id, $auth)
global $lang;
if ($auth < AUTH_UPLOAD) {
echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.DOKU_LF;
echo '<div class="nothing">' . $lang['media_perm_upload'] . '</div>' . DOKU_LF;
return false;
}
@ -186,8 +186,8 @@ function media_metaform($id, $auth)
// prepare attributes
$p = [
'class' => 'edit',
'id' => 'meta__'.$key,
'name' => 'meta['.$field[0].']'
'id' => 'meta__' . $key,
'name' => 'meta[' . $field[0] . ']'
];
$form->addTagOpen('div')->addClass('row');
@ -256,7 +256,7 @@ function media_inuse($id)
function media_delete($id, $auth)
{
global $lang;
$auth = auth_quickaclcheck(ltrim(getNS($id).':*', ':'));
$auth = auth_quickaclcheck(ltrim(getNS($id) . ':*', ':'));
if ($auth < AUTH_DELETE) return DOKU_MEDIA_NOT_AUTH;
if (media_inuse($id)) return DOKU_MEDIA_INUSE;
@ -313,7 +313,7 @@ function media_upload_xhr($ns, $auth)
[$ext, $mime] = mimetype($id);
$input = fopen("php://input", "r");
if (!($tmp = io_mktmpdir())) return false;
$path = $tmp.'/'.md5($id);
$path = $tmp . '/' . md5($id);
$target = fopen($path, "w");
$realSize = stream_copy_to_stream($input, $target);
fclose($target);
@ -325,7 +325,7 @@ function media_upload_xhr($ns, $auth)
$res = media_save(
['name' => $path, 'mime' => $mime, 'ext' => $ext],
$ns.':'.$id,
$ns . ':' . $id,
($INPUT->get->str('ow') == 'true'),
$auth,
'copy'
@ -369,7 +369,7 @@ function media_upload($ns, $auth, $file = false)
[$iext, $imime] = mimetype($id);
if ($fext && !$iext) {
// no extension specified in id - read original one
$id .= '.'.$fext;
$id .= '.' . $fext;
$imime = $fmime;
} elseif ($fext && $fext != $iext) {
// extension was changed, print warning
@ -466,7 +466,7 @@ function media_save($file, $id, $ow, $auth, $move)
$regex = implode('|', $types);
// because a temp file was created already
if (!preg_match('/\.('.$regex.')$/i', $fn)) {
if (!preg_match('/\.(' . $regex . ')$/i', $fn)) {
return [$lang['uploadwrong'], -1];
}
@ -510,7 +510,7 @@ function media_save($file, $id, $ow, $auth, $move)
function _media_upload_action($data)
{
// fixme do further sanity tests of given data?
if (is_array($data) && count($data)===6) {
if (is_array($data) && count($data) === 6) {
return media_upload_finish($data[0], $data[1], $data[2], $data[3], $data[4], $data[5]);
} else {
return false; //callback error
@ -713,11 +713,11 @@ function media_filelist($ns, $auth = null, $jump = '', $fullscreenview = false,
// check auth our self if not given (needed for ajax calls)
if (is_null($auth)) $auth = auth_quickaclcheck("$ns:*");
if (!$fullscreenview) echo '<h1 id="media__ns">:'.hsc($ns).'</h1>'.NL;
if (!$fullscreenview) echo '<h1 id="media__ns">:' . hsc($ns) . '</h1>' . NL;
if ($auth < AUTH_READ) {
// FIXME: print permission warning here instead?
echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL;
echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
} else {
if (!$fullscreenview) {
media_uploadform($ns, $auth);
@ -730,14 +730,14 @@ function media_filelist($ns, $auth = null, $jump = '', $fullscreenview = false,
$data,
$conf['mediadir'],
'search_mediafiles',
['showmsg'=>true, 'depth'=>1],
['showmsg' => true, 'depth' => 1],
$dir,
1,
$sort
);
if (!count($data)) {
echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL;
echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
} else {
if ($fullscreenview) {
echo '<ul class="' . _media_get_list_type() . '">';
@ -757,7 +757,7 @@ function media_filelist($ns, $auth = null, $jump = '', $fullscreenview = false,
echo '</li>';
}
}
if ($fullscreenview) echo '</ul>'.NL;
if ($fullscreenview) echo '</ul>' . NL;
}
}
}
@ -850,7 +850,7 @@ function media_tab_files_options()
if ($INPUT->has('q')) {
$form->setHiddenField('q', $INPUT->str('q'));
}
$form->addHTML('<ul>'.NL);
$form->addHTML('<ul>' . NL);
foreach (
[
'list' => ['listType', ['thumbs', 'rows']],
@ -860,24 +860,24 @@ function media_tab_files_options()
$checked = "_media_get_{$group}_type";
$checked = $checked();
$form->addHTML('<li class="'. $content[0] .'">');
$form->addHTML('<li class="' . $content[0] . '">');
foreach ($content[1] as $option) {
$attrs = [];
if ($checked == $option) {
$attrs['checked'] = 'checked';
}
$radio = $form->addRadioButton(
$group.'_dwmedia',
$lang['media_'.$group.'_'.$option]
)->val($option)->id($content[0].'__'.$option)->addClass($option);
$group . '_dwmedia',
$lang['media_' . $group . '_' . $option]
)->val($option)->id($content[0] . '__' . $option)->addClass($option);
$radio->attrs($attrs);
}
$form->addHTML('</li>'.NL);
$form->addHTML('</li>' . NL);
}
$form->addHTML('<li>');
$form->addButton('', $lang['btn_apply'])->attr('type', 'submit');
$form->addHTML('</li>'.NL);
$form->addHTML('</ul>'.NL);
$form->addHTML('</li>' . NL);
$form->addHTML('</ul>' . NL);
$form->addTagClose('div');
echo $form->toHTML();
}
@ -943,7 +943,7 @@ function media_tab_files($ns, $auth = null, $jump = '')
if (is_null($auth)) $auth = auth_quickaclcheck("$ns:*");
if ($auth < AUTH_READ) {
echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL;
echo '<div class="nothing">' . $lang['media_perm_read'] . '</div>' . NL;
} else {
media_filelist($ns, $auth, $jump, true, _media_get_sort_type());
}
@ -963,12 +963,12 @@ function media_tab_upload($ns, $auth = null, $jump = '')
global $lang;
if (is_null($auth)) $auth = auth_quickaclcheck("$ns:*");
echo '<div class="upload">'.NL;
echo '<div class="upload">' . NL;
if ($auth >= AUTH_UPLOAD) {
echo '<p>' . $lang['mediaupload'] . '</p>';
}
media_uploadform($ns, $auth, true);
echo '</div>'.NL;
echo '</div>' . NL;
}
/**
@ -985,13 +985,13 @@ function media_tab_search($ns, $auth = null)
$do = $INPUT->str('mediado');
$query = $INPUT->str('q');
echo '<div class="search">'.NL;
echo '<div class="search">' . NL;
media_searchform($ns, $query, true);
if ($do == 'searchlist' || $query) {
media_searchlist($query, $ns, $auth, true, _media_get_sort_type());
}
echo '</div>'.NL;
echo '</div>' . NL;
}
/**
@ -1015,7 +1015,7 @@ function media_tab_view($image, $ns, $auth = null, $rev = '')
media_preview_buttons($image, $auth, $rev);
media_details($image, $auth, $rev, $meta);
} else {
echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL;
echo '<div class="nothing">' . $lang['media_perm_read'] . '</div>' . NL;
}
}
@ -1063,7 +1063,7 @@ function media_tab_history($image, $ns, $auth = null)
(new MediaRevisions($image))->show($first);
}
} else {
echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL;
echo '<div class="nothing">' . $lang['media_perm_read'] . '</div>' . NL;
}
}
@ -1098,8 +1098,8 @@ function media_preview($image, $auth, $rev = '', $meta = false)
$more['h'] = $size[1];
$src = ml($image, $more);
echo '<a href="'.$src.'" target="_blank" title="'.$lang['mediaview'].'">';
echo '<img src="'.$src.'" alt="" style="max-width: '.$size[0].'px;" />';
echo '<a href="' . $src . '" target="_blank" title="' . $lang['mediaview'] . '">';
echo '<img src="' . $src . '" alt="" style="max-width: ' . $size[0] . 'px;" />';
echo '</a>';
echo '</div>';
@ -1154,7 +1154,7 @@ function media_preview_buttons($image, $auth, $rev = '')
// restore button
$form = new Form([
'id' => 'mediamanager__btn_restore',
'action'=>media_managerURL(['image' => $image], '&'),
'action' => media_managerURL(['image' => $image], '&'),
]);
$form->addTagOpen('div')->addClass('no');
$form->setHiddenField('mediado', 'restore');
@ -1265,28 +1265,28 @@ function media_details($image, $auth, $rev = '', $meta = false)
if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev));
$tags = media_file_tags($meta);
echo '<dl>'.NL;
echo '<dl>' . NL;
foreach ($tags as $tag) {
if ($tag['value']) {
$value = cleanText($tag['value']);
echo '<dt>'.$lang[$tag['tag'][1]].'</dt><dd>';
echo '<dt>' . $lang[$tag['tag'][1]] . '</dt><dd>';
if ($tag['tag'][2] == 'date') echo dformat($value);
else echo hsc($value);
echo '</dd>'.NL;
echo '</dd>' . NL;
}
}
echo '</dl>'.NL;
echo '<dl>'.NL;
echo '<dt>'.$lang['reference'].':</dt>';
echo '</dl>' . NL;
echo '<dl>' . NL;
echo '<dt>' . $lang['reference'] . ':</dt>';
$media_usage = ft_mediause($image, true);
if ($media_usage !== []) {
foreach ($media_usage as $path) {
echo '<dd>'.html_wikilink($path).'</dd>';
echo '<dd>' . html_wikilink($path) . '</dd>';
}
} else {
echo '<dd>'.$lang['nothingfound'].'</dd>';
echo '<dd>' . $lang['nothingfound'] . '</dd>';
}
echo '</dl>'.NL;
echo '</dl>' . NL;
}
@ -1304,7 +1304,7 @@ function media_details($image, $auth, $rev = '', $meta = false)
*/
function media_diff($image, $ns, $auth, $fromajax = false)
{
dbg_deprecated('see '. MediaDiff::class .'::show()');
dbg_deprecated('see ' . MediaDiff::class . '::show()');
}
/**
@ -1316,7 +1316,7 @@ function media_diff($image, $ns, $auth, $fromajax = false)
*/
function _media_file_diff($data)
{
dbg_deprecated('see '. MediaDiff::class .'::show()');
dbg_deprecated('see ' . MediaDiff::class . '::show()');
}
/**
@ -1334,7 +1334,7 @@ function _media_file_diff($data)
*/
function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax)
{
dbg_deprecated('see '. MediaDiff::class .'::showFileDiff()');
dbg_deprecated('see ' . MediaDiff::class . '::showFileDiff()');
}
/**
@ -1353,7 +1353,7 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax)
*/
function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type)
{
dbg_deprecated('see '. MediaDiff::class .'::showImageDiff()');
dbg_deprecated('see ' . MediaDiff::class . '::showImageDiff()');
}
/**
@ -1423,14 +1423,14 @@ function media_searchlist($query, $ns, $auth = null, $fullscreen = false, $sort
$quoted = str_replace(['\*', '\?'], ['.*', '.'], $quoted, $count);
//if we use globbing file name must match entirely but may be preceded by arbitrary namespace
if ($count > 0) $quoted = '^([^:]*:)*'.$quoted.'$';
if ($count > 0) $quoted = '^([^:]*:)*' . $quoted . '$';
$pattern = '/'.$quoted.'/i';
$pattern = '/' . $quoted . '/i';
search(
$evdata['data'],
$conf['mediadir'],
'search_mediafiles',
['showmsg'=>false, 'pattern'=>$pattern],
['showmsg' => false, 'pattern' => $pattern],
$dir,
1,
$sort
@ -1441,12 +1441,12 @@ function media_searchlist($query, $ns, $auth = null, $fullscreen = false, $sort
}
if (!$fullscreen) {
echo '<h1 id="media__ns">'.sprintf($lang['searchmedia_in'], hsc($ns).':*').'</h1>'.NL;
echo '<h1 id="media__ns">' . sprintf($lang['searchmedia_in'], hsc($ns) . ':*') . '</h1>' . NL;
media_searchform($ns, $query);
}
if (!count($evdata['data'])) {
echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL;
echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
} else {
if ($fullscreen) {
echo '<ul class="' . _media_get_list_type() . '">';
@ -1466,7 +1466,7 @@ function media_searchlist($query, $ns, $auth = null, $fullscreen = false, $sort
echo '</li>';
}
}
if ($fullscreen) echo '</ul>'.NL;
if ($fullscreen) echo '</ul>' . NL;
}
}
@ -1481,13 +1481,13 @@ function media_printicon($filename, $size = '')
{
[$ext] = mimetype(mediaFN($filename), false);
if (file_exists(DOKU_INC.'lib/images/fileicons/'.$size.'/'.$ext.'.png')) {
$icon = DOKU_BASE.'lib/images/fileicons/'.$size.'/'.$ext.'.png';
if (file_exists(DOKU_INC . 'lib/images/fileicons/' . $size . '/' . $ext . '.png')) {
$icon = DOKU_BASE . 'lib/images/fileicons/' . $size . '/' . $ext . '.png';
} else {
$icon = DOKU_BASE.'lib/images/fileicons/'.$size.'/file.png';
$icon = DOKU_BASE . 'lib/images/fileicons/' . $size . '/file.png';
}
return '<img src="'.$icon.'" alt="'.$filename.'" class="icon" />';
return '<img src="' . $icon . '" alt="' . $filename . '" class="icon" />';
}
/**
@ -1543,7 +1543,7 @@ function media_uploadform($ns, $auth, $fullscreen = false)
global $INPUT;
if ($auth < AUTH_UPLOAD) {
echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.NL;
echo '<div class="nothing">' . $lang['media_perm_upload'] . '</div>' . NL;
return;
}
$auth_ow = (($conf['mediarevisions']) ? AUTH_UPLOAD : AUTH_DELETE);
@ -1561,7 +1561,7 @@ function media_uploadform($ns, $auth, $fullscreen = false)
'enctype' => 'multipart/form-data',
'action' => ($fullscreen)
? media_managerURL(['tab_files' => 'files', 'tab_details' => 'view'], '&')
: DOKU_BASE.'lib/exe/mediamanager.php',
: DOKU_BASE . 'lib/exe/mediamanager.php',
]);
$form->addTagOpen('div')->addClass('no');
$form->setHiddenField('ns', hsc($ns)); // FIXME hsc required?
@ -1585,20 +1585,20 @@ function media_uploadform($ns, $auth, $fullscreen = false)
$form->addTagClose('div');
if (!$fullscreen) {
echo '<div class="upload">'. $lang['mediaupload'] .'</div>'.DOKU_LF;
echo '<div class="upload">' . $lang['mediaupload'] . '</div>' . DOKU_LF;
} else {
echo DOKU_LF;
}
echo '<div id="mediamanager__uploader">'.DOKU_LF;
echo '<div id="mediamanager__uploader">' . DOKU_LF;
echo $form->toHTML('Upload');
echo '</div>'.DOKU_LF;
echo '</div>' . DOKU_LF;
echo '<p class="maxsize">';
printf($lang['maxuploadsize'], filesize_h(media_getuploadsize()));
echo ' <a class="allowedmime" href="#">'. $lang['allowedmime'] .'</a>';
echo ' <span>'. implode(', ', array_keys(getMimeTypes())) .'</span>';
echo '</p>'.DOKU_LF;
echo ' <a class="allowedmime" href="#">' . $lang['allowedmime'] . '</a>';
echo ' <span>' . implode(', ', array_keys(getMimeTypes())) . '</span>';
echo '</p>' . DOKU_LF;
}
/**
@ -1643,7 +1643,7 @@ function media_searchform($ns, $query = '', $fullscreen = false)
'id' => 'dw__mediasearch',
'action' => ($fullscreen)
? media_managerURL([], '&')
: DOKU_BASE.'lib/exe/mediamanager.php',
: DOKU_BASE . 'lib/exe/mediamanager.php',
]);
$form->addTagOpen('div')->addClass('no');
$form->setHiddenField('ns', $ns);
@ -1651,7 +1651,7 @@ function media_searchform($ns, $query = '', $fullscreen = false)
$form->addTagOpen('p');
$form->addTextInput('q', $lang['searchmedia'])
->attr('title', sprintf($lang['searchmedia_in'], hsc($ns) .':*'))
->attr('title', sprintf($lang['searchmedia_in'], hsc($ns) . ':*'))
->val($query);
$form->addHTML(' ');
$form->addButton('', $lang['btn_search'])->attr('type', 'submit');
@ -1685,23 +1685,23 @@ function media_nstree($ns)
search($data, $conf['mediadir'], 'search_index', ['ns' => $ns_dir, 'nofiles' => true]);
// wrap a list with the root level around the other namespaces
array_unshift($data, ['level' => 0, 'id' => '', 'open' =>'true', 'label' => '['.$lang['mediaroot'].']']);
array_unshift($data, ['level' => 0, 'id' => '', 'open' => 'true', 'label' => '[' . $lang['mediaroot'] . ']']);
// insert the current ns into the hierarchy if it isn't already part of it
$ns_parts = explode(':', $ns);
$tmp_ns = '';
$pos = 0;
foreach ($ns_parts as $level => $part) {
if ($tmp_ns) $tmp_ns .= ':'.$part;
if ($tmp_ns) $tmp_ns .= ':' . $part;
else $tmp_ns = $part;
// find the namespace parts or insert them
while ($data[$pos]['id'] != $tmp_ns) {
if (
$pos >= count($data) ||
($data[$pos]['level'] <= $level+1 && Sort::strcmp($data[$pos]['id'], $tmp_ns) > 0)
($data[$pos]['level'] <= $level + 1 && Sort::strcmp($data[$pos]['id'], $tmp_ns) > 0)
) {
array_splice($data, $pos, 0, [['level' => $level+1, 'id' => $tmp_ns, 'open' => 'true']]);
array_splice($data, $pos, 0, [['level' => $level + 1, 'id' => $tmp_ns, 'open' => 'true']]);
break;
}
++$pos;
@ -1730,9 +1730,9 @@ function media_nstree_item($item)
$ret = '';
if ($INPUT->str('do') != 'media')
$ret .= '<a href="'.DOKU_BASE.'lib/exe/mediamanager.php?ns='.idfilter($item['id']).'" class="idx_dir">';
else $ret .= '<a href="'.media_managerURL(['ns' => idfilter($item['id'], false), 'tab_files' => 'files'])
.'" class="idx_dir">';
$ret .= '<a href="' . DOKU_BASE . 'lib/exe/mediamanager.php?ns=' . idfilter($item['id']) . '" class="idx_dir">';
else $ret .= '<a href="' . media_managerURL(['ns' => idfilter($item['id'], false), 'tab_files' => 'files'])
. '" class="idx_dir">';
$ret .= $item['label'];
$ret .= '</a>';
return $ret;
@ -1750,19 +1750,19 @@ function media_nstree_item($item)
*/
function media_nstree_li($item)
{
$class='media level'.$item['level'];
$class = 'media level' . $item['level'];
if ($item['open']) {
$class .= ' open';
$img = DOKU_BASE.'lib/images/minus.gif';
$img = DOKU_BASE . 'lib/images/minus.gif';
$alt = '';
} else {
$class .= ' closed';
$img = DOKU_BASE.'lib/images/plus.gif';
$img = DOKU_BASE . 'lib/images/plus.gif';
$alt = '+';
}
// TODO: only deliver an image if it actually has a subtree...
return '<li class="'.$class.'">'.
'<img src="'.$img.'" alt="'.$alt.'" />';
return '<li class="' . $class . '">' .
'<img src="' . $img . '" alt="' . $alt . '" />';
}
/**
@ -1857,8 +1857,8 @@ function media_get_token($id, $w, $h)
// token is only required for modified images
if ($w || $h || media_isexternal($id)) {
$token = $id;
if ($w) $token .= '.'.$w;
if ($h) $token .= '.'.$h;
if ($w) $token .= '.' . $w;
if ($h) $token .= '.' . $h;
return substr(PassHash::hmac('md5', $token, auth_cookiesalt()), 0, 6);
}
@ -1885,7 +1885,7 @@ function media_get_from_URL($url, $ext, $cache)
global $conf;
// if no cache or fetchsize just redirect
if ($cache==0) return false;
if ($cache == 0) return false;
if (!$conf['fetchsize']) return false;
$local = getCacheName(strtolower($url), ".media.$ext");
@ -1973,9 +1973,9 @@ function media_resize_imageIM($ext, $from, $from_w, $from_h, $to, $to_w, $to_h)
// prepare command
$cmd = $conf['im_convert'];
$cmd .= ' -resize '.$to_w.'x'.$to_h.'!';
$cmd .= ' -resize ' . $to_w . 'x' . $to_h . '!';
if ($ext == 'jpg' || $ext == 'jpeg') {
$cmd .= ' -quality '.$conf['jpg_quality'];
$cmd .= ' -quality ' . $conf['jpg_quality'];
}
$cmd .= " $from $to";
@ -2011,9 +2011,9 @@ function media_crop_imageIM($ext, $from, $from_w, $from_h, $to, $to_w, $to_h, $o
// prepare command
$cmd = $conf['im_convert'];
$cmd .= ' -crop '.$to_w.'x'.$to_h.'+'.$ofs_x.'+'.$ofs_y;
$cmd .= ' -crop ' . $to_w . 'x' . $to_h . '+' . $ofs_x . '+' . $ofs_y;
if ($ext == 'jpg' || $ext == 'jpeg') {
$cmd .= ' -quality '.$conf['jpg_quality'];
$cmd .= ' -quality ' . $conf['jpg_quality'];
}
$cmd .= " $from $to";
@ -2067,7 +2067,7 @@ function media_resize_imageGD($ext, $from, $from_w, $from_h, $to, $to_w, $to_h,
if (!$image) return false;
$newimg = false;
if (($conf['gdlib']>1) && function_exists("imagecreatetruecolor") && $ext != 'gif') {
if (($conf['gdlib'] > 1) && function_exists("imagecreatetruecolor") && $ext != 'gif') {
$newimg = @imagecreatetruecolor($to_w, $to_h);
}
if (!$newimg) $newimg = @imagecreate($to_w, $to_h);
@ -2077,7 +2077,7 @@ function media_resize_imageGD($ext, $from, $from_w, $from_h, $to, $to_w, $to_h,
}
//keep png alpha channel if possible
if ($ext == 'png' && $conf['gdlib']>1 && function_exists('imagesavealpha')) {
if ($ext == 'png' && $conf['gdlib'] > 1 && function_exists('imagesavealpha')) {
imagealphablending($newimg, false);
imagesavealpha($newimg, true);
}
@ -2158,10 +2158,10 @@ function media_alternativefiles($src, $exts)
$files = [];
[$srcExt, /* srcMime */] = mimetype($src);
$filebase = substr($src, 0, -1 * (strlen($srcExt)+1));
$filebase = substr($src, 0, -1 * (strlen($srcExt) + 1));
foreach ($exts as $ext) {
$fileid = $filebase.'.'.$ext;
$fileid = $filebase . '.' . $ext;
$file = mediaFN($fileid);
if (file_exists($file)) {
[/* fileExt */, $fileMime] = mimetype($file);
@ -2214,7 +2214,7 @@ function media_supportedav($mime, $type = null)
*/
function media_trackfiles($src)
{
$kinds=[
$kinds = [
'sub' => 'subtitles',
'cap' => 'captions',
'des' => 'descriptions',
@ -2223,13 +2223,13 @@ function media_trackfiles($src)
];
$files = [];
$re='/\\.(sub|cap|des|cha|met)\\.([^.]+)\\.vtt$/';
$baseid=pathinfo($src, PATHINFO_FILENAME);
$pattern=mediaFN($baseid).'.*.*.vtt';
$list=glob($pattern);
$re = '/\\.(sub|cap|des|cha|met)\\.([^.]+)\\.vtt$/';
$baseid = pathinfo($src, PATHINFO_FILENAME);
$pattern = mediaFN($baseid) . '.*.*.vtt';
$list = glob($pattern);
foreach ($list as $track) {
if (preg_match($re, $track, $matches)) {
$files[$baseid.'.'.$matches[1].'.'.$matches[2].'.vtt']=[$kinds[$matches[1]], $matches[2]];
$files[$baseid . '.' . $matches[1] . '.' . $matches[2] . '.vtt'] = [$kinds[$matches[1]], $matches[2]];
}
}
return $files;

View File

@ -11,7 +11,7 @@ use dokuwiki\Extension\AdminPlugin;
use dokuwiki\Extension\PluginController;
use dokuwiki\Extension\PluginInterface;
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/');
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
// note that only [a-z0-9]+ is officially supported,
// this is only to support plugins that don't follow these conventions, too
if (!defined('DOKU_PLUGIN_NAME_REGEX')) define('DOKU_PLUGIN_NAME_REGEX', '[a-zA-Z0-9\x7f-\xff]+');
@ -32,7 +32,7 @@ function plugin_list($type = '', $all = false)
/** @var $plugin_controller PluginController */
global $plugin_controller;
$plugins = $plugin_controller->getList($type, $all);
sort($plugins, SORT_NATURAL|SORT_FLAG_CASE);
sort($plugins, SORT_NATURAL | SORT_FLAG_CASE);
return $plugins;
}

View File

@ -37,16 +37,16 @@ function search(&$data, $base, $func, $opts, $dir = '', $lvl = 1, $sort = 'natur
}
//read in directories and files
$dh = @opendir($base.'/'.$dir);
$dh = @opendir($base . '/' . $dir);
if (!$dh) return;
while (($file = readdir($dh)) !== false) {
if (preg_match('/^[\._]/', $file)) continue; //skip hidden files and upper dirs
if (is_dir($base.'/'.$dir.'/'.$file)) {
$dirs[] = $dir.'/'.$file;
if (is_dir($base . '/' . $dir . '/' . $file)) {
$dirs[] = $dir . '/' . $file;
continue;
}
$files[] = $dir.'/'.$file;
$filepaths[] = $base.'/'.$dir.'/'.$file;
$files[] = $dir . '/' . $file;
$filepaths[] = $base . '/' . $dir . '/' . $file;
}
closedir($dh);
if (!empty($sort)) {
@ -61,7 +61,7 @@ function search(&$data, $base, $func, $opts, $dir = '', $lvl = 1, $sort = 'natur
//give directories to userfunction then recurse
foreach ($dirs as $dir) {
if (call_user_func_array($func, [&$data, $base, $dir, 'd', $lvl, $opts])) {
search($data, $base, $func, $opts, $dir, $lvl+1, $sort);
search($data, $base, $func, $opts, $dir, $lvl + 1, $sort);
}
}
//now handle the files
@ -110,7 +110,7 @@ function search(&$data, $base, $func, $opts, $dir = '', $lvl = 1, $sort = 'natur
function search_qsearch(&$data, $base, $file, $type, $lvl, $opts)
{
$opts = [
'idmatch' => '(^|:)'.preg_quote($opts['query'], '/').'/',
'idmatch' => '(^|:)' . preg_quote($opts['query'], '/') . '/',
'listfiles' => true,
'pagesonly' => true
];
@ -143,7 +143,7 @@ function search_index(&$data, $base, $file, $type, $lvl, $opts)
'listfiles' => empty($opts['nofiles']),
'sneakyacl' => $conf['sneaky_index'],
// Hacky, should rather use recmatch
'depth' => preg_match('#^'.preg_quote($file, '#').'(/|$)#', '/'.$ns) ? 0 : -1,
'depth' => preg_match('#^' . preg_quote($file, '#') . '(/|$)#', '/' . $ns) ? 0 : -1,
];
return search_universal($data, $base, $file, $type, $lvl, $opts);
@ -203,12 +203,12 @@ function search_media(&$data, $base, $file, $type, $lvl, $opts)
$info['id'] = pathID($file, true);
if ($info['id'] != cleanID($info['id'])) {
if (!empty($opts['showmsg']))
msg(hsc($info['id']).' is not a valid file name for DokuWiki - skipped', -1);
msg(hsc($info['id']) . ' is not a valid file name for DokuWiki - skipped', -1);
return false; // skip non-valid files
}
//check ACL for namespace (we have no ACL for mediafiles)
$info['perm'] = auth_quickaclcheck(getNS($info['id']).':*');
$info['perm'] = auth_quickaclcheck(getNS($info['id']) . ':*');
if (empty($opts['skipacl']) && $info['perm'] < AUTH_READ) {
return false;
}
@ -219,12 +219,12 @@ function search_media(&$data, $base, $file, $type, $lvl, $opts)
}
$info['file'] = PhpString::basename($file);
$info['size'] = filesize($base.'/'.$file);
$info['mtime'] = filemtime($base.'/'.$file);
$info['writable'] = is_writable($base.'/'.$file);
$info['size'] = filesize($base . '/' . $file);
$info['mtime'] = filemtime($base . '/' . $file);
$info['writable'] = is_writable($base . '/' . $file);
if (preg_match("/\.(jpe?g|gif|png)$/", $file)) {
$info['isimg'] = true;
$info['meta'] = new JpegMeta($base.'/'.$file);
$info['meta'] = new JpegMeta($base . '/' . $file);
} else {
$info['isimg'] = false;
}
@ -270,12 +270,12 @@ function search_mediafiles(&$data, $base, $file, $type, $lvl, $opts)
$id = pathID($file, true);
if ($id != cleanID($id)) {
if ($opts['showmsg'])
msg(hsc($id).' is not a valid file name for DokuWiki - skipped', -1);
msg(hsc($id) . ' is not a valid file name for DokuWiki - skipped', -1);
return false; // skip non-valid files
}
//check ACL for namespace (we have no ACL for mediafiles)
$info['perm'] = auth_quickaclcheck(getNS($id).':*');
$info['perm'] = auth_quickaclcheck(getNS($id) . ':*');
if (empty($opts['skipacl']) && $info['perm'] < AUTH_READ) {
return false;
}
@ -401,9 +401,9 @@ function search_allpages(&$data, $base, $file, $type, $lvl, $opts)
return false;
}
$item['rev'] = filemtime($base.'/'.$file);
$item['rev'] = filemtime($base . '/' . $file);
$item['mtime'] = $item['rev'];
$item['size'] = filesize($base.'/'.$file);
$item['size'] = filesize($base . '/' . $file);
if (!empty($opts['hash'])) {
$item['hash'] = md5(trim(rawWiki($item['id'])));
}
@ -505,7 +505,7 @@ function search_universal(&$data, $base, $file, $type, $lvl, $opts)
$item['id'] = pathID($file, ($type == 'd' || !empty($opts['keeptxt'])));
if ($item['id'] != cleanID($item['id'])) {
if (!empty($opts['showmsg'])) {
msg(hsc($item['id']).' is not a valid file name for DokuWiki - skipped', -1);
msg(hsc($item['id']) . ' is not a valid file name for DokuWiki - skipped', -1);
}
return false; // skip non-valid files
}
@ -525,7 +525,7 @@ function search_universal(&$data, $base, $file, $type, $lvl, $opts)
}
if ($return) {
$match = empty($opts['recmatch']) || preg_match('/'.$opts['recmatch'].'/', $file);
$match = empty($opts['recmatch']) || preg_match('/' . $opts['recmatch'] . '/', $file);
if (!$match) {
return false; // doesn't match
}
@ -535,7 +535,7 @@ function search_universal(&$data, $base, $file, $type, $lvl, $opts)
// check ACL
if (empty($opts['skipacl'])) {
if ($type == 'd') {
$item['perm'] = auth_quickaclcheck($item['id'].':*');
$item['perm'] = auth_quickaclcheck($item['id'] . ':*');
} else {
$item['perm'] = auth_quickaclcheck($item['id']); //FIXME check namespace for media files
}
@ -548,15 +548,15 @@ function search_universal(&$data, $base, $file, $type, $lvl, $opts)
if (empty($opts['listdirs'])) return $return;
//neither list nor recurse forbidden items:
if (empty($opts['skipacl']) && !empty($opts['sneakyacl']) && $item['perm'] < AUTH_READ) return false;
if (!empty($opts['dirmatch']) && !preg_match('/'.$opts['dirmatch'].'/', $file)) return $return;
if (!empty($opts['nsmatch']) && !preg_match('/'.$opts['nsmatch'].'/', $item['ns'])) return $return;
if (!empty($opts['dirmatch']) && !preg_match('/' . $opts['dirmatch'] . '/', $file)) return $return;
if (!empty($opts['nsmatch']) && !preg_match('/' . $opts['nsmatch'] . '/', $item['ns'])) return $return;
} else {
if (empty($opts['listfiles'])) return $return;
if (empty($opts['skipacl']) && $item['perm'] < AUTH_READ) return $return;
if (!empty($opts['pagesonly']) && (substr($file, -4) != '.txt')) return $return;
if (empty($opts['showhidden']) && isHiddenPage($item['id'])) return $return;
if (!empty($opts['filematch']) && !preg_match('/'.$opts['filematch'].'/', $file)) return $return;
if (!empty($opts['idmatch']) && !preg_match('/'.$opts['idmatch'].'/', $item['id'])) return $return;
if (!empty($opts['filematch']) && !preg_match('/' . $opts['filematch'] . '/', $file)) return $return;
if (!empty($opts['idmatch']) && !preg_match('/' . $opts['idmatch'] . '/', $item['id'])) return $return;
}
// still here? prepare the item
@ -566,15 +566,15 @@ function search_universal(&$data, $base, $file, $type, $lvl, $opts)
if (!empty($opts['meta'])) {
$item['file'] = PhpString::basename($file);
$item['size'] = filesize($base.'/'.$file);
$item['mtime'] = filemtime($base.'/'.$file);
$item['size'] = filesize($base . '/' . $file);
$item['mtime'] = filemtime($base . '/' . $file);
$item['rev'] = $item['mtime'];
$item['writable'] = is_writable($base.'/'.$file);
$item['executable'] = is_executable($base.'/'.$file);
$item['writable'] = is_writable($base . '/' . $file);
$item['executable'] = is_executable($base . '/' . $file);
}
if ($type == 'f') {
if (!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base.'/'.$file, false));
if (!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base . '/' . $file, false));
if (!empty($opts['firsthead'])) $item['title'] = p_get_first_heading($item['id'], METADATA_DONT_RENDER);
}

View File

@ -32,10 +32,10 @@ function template($file)
{
global $conf;
if (@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$file))
return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$file;
if (@is_readable(DOKU_INC . 'lib/tpl/' . $conf['template'] . '/' . $file))
return DOKU_INC . 'lib/tpl/' . $conf['template'] . '/' . $file;
return DOKU_INC.'lib/tpl/dokuwiki/'.$file;
return DOKU_INC . 'lib/tpl/dokuwiki/' . $file;
}
/**
@ -51,7 +51,7 @@ function tpl_incdir($tpl = '')
{
global $conf;
if (!$tpl) $tpl = $conf['template'];
return DOKU_INC.'lib/tpl/'.$tpl.'/';
return DOKU_INC . 'lib/tpl/' . $tpl . '/';
}
/**
@ -67,7 +67,7 @@ function tpl_basedir($tpl = '')
{
global $conf;
if (!$tpl) $tpl = $conf['template'];
return DOKU_BASE.'lib/tpl/'.$tpl.'/';
return DOKU_BASE . 'lib/tpl/' . $tpl . '/';
}
/**
@ -239,34 +239,34 @@ function tpl_metaheaders($alt = true)
// prepare seed for js and css
$tseed = $updateVersion;
$depends = getConfigFiles('main');
$depends[] = DOKU_CONF."tpl/".$conf['template']."/style.ini";
$depends[] = DOKU_CONF . "tpl/" . $conf['template'] . "/style.ini";
foreach ($depends as $f) $tseed .= @filemtime($f);
$tseed = md5($tseed);
// the usual stuff
$head['meta'][] = ['name'=> 'generator', 'content'=> 'DokuWiki'];
$head['meta'][] = ['name' => 'generator', 'content' => 'DokuWiki'];
if (actionOK('search')) {
$head['link'][] = [
'rel' => 'search',
'type'=> 'application/opensearchdescription+xml',
'href'=> DOKU_BASE.'lib/exe/opensearch.php',
'title'=> $conf['title']
'type' => 'application/opensearchdescription+xml',
'href' => DOKU_BASE . 'lib/exe/opensearch.php',
'title' => $conf['title']
];
}
$head['link'][] = ['rel'=> 'start', 'href'=> DOKU_BASE];
$head['link'][] = ['rel' => 'start', 'href' => DOKU_BASE];
if (actionOK('index')) {
$head['link'][] = [
'rel' => 'contents',
'href'=> wl($ID, 'do=index', false, '&'),
'title'=> $lang['btn_index']
'href' => wl($ID, 'do=index', false, '&'),
'title' => $lang['btn_index']
];
}
if (actionOK('manifest')) {
$head['link'][] = [
'rel'=> 'manifest',
'href'=> DOKU_BASE.'lib/exe/manifest.php'
'rel' => 'manifest',
'href' => DOKU_BASE . 'lib/exe/manifest.php'
];
}
@ -284,21 +284,21 @@ function tpl_metaheaders($alt = true)
if (actionOK('rss')) {
$head['link'][] = [
'rel' => 'alternate',
'type'=> 'application/rss+xml',
'title'=> $lang['btn_recent'],
'href'=> DOKU_BASE.'feed.php'
'type' => 'application/rss+xml',
'title' => $lang['btn_recent'],
'href' => DOKU_BASE . 'feed.php'
];
$head['link'][] = [
'rel' => 'alternate',
'type'=> 'application/rss+xml',
'title'=> $lang['currentns'],
'href' => DOKU_BASE.'feed.php?mode=list&ns='.(isset($INFO) ? $INFO['namespace'] : '')
'type' => 'application/rss+xml',
'title' => $lang['currentns'],
'href' => DOKU_BASE . 'feed.php?mode=list&ns=' . (isset($INFO) ? $INFO['namespace'] : '')
];
}
if (($ACT == 'show' || $ACT == 'search') && $INFO['writable']) {
$head['link'][] = [
'rel' => 'edit',
'title'=> $lang['btn_edit'],
'title' => $lang['btn_edit'],
'href' => wl($ID, 'do=edit', false, '&')
];
}
@ -306,27 +306,27 @@ function tpl_metaheaders($alt = true)
if (actionOK('rss') && $ACT == 'search') {
$head['link'][] = [
'rel' => 'alternate',
'type'=> 'application/rss+xml',
'title'=> $lang['searchresult'],
'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY
'type' => 'application/rss+xml',
'title' => $lang['searchresult'],
'href' => DOKU_BASE . 'feed.php?mode=search&q=' . $QUERY
];
}
if (actionOK('export_xhtml')) {
$head['link'][] = [
'rel' => 'alternate',
'type'=> 'text/html',
'title'=> $lang['plainhtml'],
'href'=> exportlink($ID, 'xhtml', '', false, '&')
'type' => 'text/html',
'title' => $lang['plainhtml'],
'href' => exportlink($ID, 'xhtml', '', false, '&')
];
}
if (actionOK('export_raw')) {
$head['link'][] = [
'rel' => 'alternate',
'type'=> 'text/plain',
'title'=> $lang['wikimarkup'],
'href'=> exportlink($ID, 'raw', '', false, '&')
'type' => 'text/plain',
'title' => $lang['wikimarkup'],
'href' => exportlink($ID, 'raw', '', false, '&')
];
}
}
@ -336,47 +336,47 @@ function tpl_metaheaders($alt = true)
if ($INFO['exists']) {
//delay indexing:
if ((time() - $INFO['lastmod']) >= $conf['indexdelay'] && !isHiddenPage($ID)) {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'index,follow'];
$head['meta'][] = ['name' => 'robots', 'content' => 'index,follow'];
} else {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'noindex,nofollow'];
$head['meta'][] = ['name' => 'robots', 'content' => 'noindex,nofollow'];
}
$canonicalUrl = wl($ID, '', true, '&');
if ($ID == $conf['start']) {
$canonicalUrl = DOKU_URL;
}
$head['link'][] = ['rel'=> 'canonical', 'href'=> $canonicalUrl];
$head['link'][] = ['rel' => 'canonical', 'href' => $canonicalUrl];
} else {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'noindex,follow'];
$head['meta'][] = ['name' => 'robots', 'content' => 'noindex,follow'];
}
} elseif (defined('DOKU_MEDIADETAIL')) {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'index,follow'];
$head['meta'][] = ['name' => 'robots', 'content' => 'index,follow'];
} else {
$head['meta'][] = ['name'=> 'robots', 'content'=> 'noindex,nofollow'];
$head['meta'][] = ['name' => 'robots', 'content' => 'noindex,nofollow'];
}
// set metadata
if ($ACT == 'show' || $ACT == 'export_xhtml') {
// keywords (explicit or implicit)
if (!empty($INFO['meta']['subject'])) {
$head['meta'][] = ['name'=> 'keywords', 'content'=> implode(',', $INFO['meta']['subject'])];
$head['meta'][] = ['name' => 'keywords', 'content' => implode(',', $INFO['meta']['subject'])];
} else {
$head['meta'][] = ['name'=> 'keywords', 'content'=> str_replace(':', ',', $ID)];
$head['meta'][] = ['name' => 'keywords', 'content' => str_replace(':', ',', $ID)];
}
}
// load stylesheets
$head['link'][] = [
'rel' => 'stylesheet',
'href'=> DOKU_BASE.'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed
'href' => DOKU_BASE . 'lib/exe/css.php?t=' . rawurlencode($conf['template']) . '&tseed=' . $tseed
];
$script = "var NS='".(isset($INFO)?$INFO['namespace']:'')."';";
$script = "var NS='" . (isset($INFO) ? $INFO['namespace'] : '') . "';";
if ($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) {
$script .= "var SIG=".toolbar_signature().";";
$script .= "var SIG=" . toolbar_signature() . ";";
}
jsinfo();
$script .= 'var JSINFO = ' . json_encode($JSINFO, JSON_THROW_ON_ERROR).';';
$head['script'][] = ['_data'=> $script];
$script .= 'var JSINFO = ' . json_encode($JSINFO, JSON_THROW_ON_ERROR) . ';';
$head['script'][] = ['_data' => $script];
// load jquery
$jquery = getCdnUrls();
@ -389,8 +389,8 @@ function tpl_metaheaders($alt = true)
// load our javascript dispatcher
$head['script'][] = [
'_data'=> '',
'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed
'_data' => '',
'src' => DOKU_BASE . 'lib/exe/js.php' . '?t=' . rawurlencode($conf['template']) . '&tseed=' . $tseed
] + ($conf['defer_js'] ? [ 'defer' => 'defer'] : []);
// trigger event here
@ -424,8 +424,8 @@ function _tpl_metaheaders_action($data)
echo '<', $tag, ' ', buildAttributes($attr);
if (isset($attr['_data']) || $tag == 'script') {
if ($tag == 'script' && isset($attr['_data']))
$attr['_data'] = "/*<![CDATA[*/".
$attr['_data'].
$attr['_data'] = "/*<![CDATA[*/" .
$attr['_data'] .
"\n/*!]]>*/";
echo '>', $attr['_data'] ?? '', '</', $tag, '>';
@ -455,8 +455,8 @@ function _tpl_metaheaders_action($data)
*/
function tpl_link($url, $name, $more = '', $return = false)
{
$out = '<a href="'.$url.'" ';
if ($more) $out .= ' '.$more;
$out = '<a href="' . $url . '" ';
if ($more) $out .= ' ' . $more;
$out .= ">$name</a>";
if ($return) return $out;
echo $out;
@ -477,7 +477,7 @@ function tpl_link($url, $name, $more = '', $return = false)
*/
function tpl_pagelink($id, $name = null, $return = false)
{
$out = '<bdi>'.html_wikilink($id, $name).'</bdi>';
$out = '<bdi>' . html_wikilink($id, $name) . '</bdi>';
if ($return) return $out;
echo $out;
return true;
@ -498,11 +498,11 @@ function tpl_getparent($id)
{
$resolver = new PageResolver('root');
$parent = getNS($id).':';
$parent = getNS($id) . ':';
$parent = $resolver->resolveId($parent);
if ($parent == $id) {
$pos = strrpos(getNS($id), ':');
$parent = substr($parent, 0, $pos).':';
$parent = substr($parent, 0, $pos) . ':';
$parent = $resolver->resolveId($parent);
if ($parent == $id) return false;
}
@ -585,23 +585,23 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals
} else {
$linktarget = wl($id, $params);
}
$caption = $lang['btn_'.$type];
$caption = $lang['btn_' . $type];
if (strpos($caption, '%s')) {
$caption = sprintf($caption, $replacement);
}
$akey = '';
$addTitle = '';
if ($accesskey) {
$akey = 'accesskey="'.$accesskey.'" ';
$addTitle = ' ['.strtoupper($accesskey).']';
$akey = 'accesskey="' . $accesskey . '" ';
$addTitle = ' [' . strtoupper($accesskey) . ']';
}
$rel = $nofollow ? 'rel="nofollow" ' : '';
$out = tpl_link(
$linktarget,
$pre.($inner ?: $caption).$suf,
'class="action '.$type.'" '.
$akey.$rel.
'title="'.hsc($caption).$addTitle.'"',
$pre . ($inner ?: $caption) . $suf,
'class="action ' . $type . '" ' .
$akey . $rel .
'title="' . hsc($caption) . $addTitle . '"',
true
);
}
@ -779,21 +779,21 @@ function tpl_breadcrumbs($sep = null, $return = false)
//set default
if (is_null($sep)) $sep = '•';
$out='';
$out = '';
$crumbs = breadcrumbs(); //setup crumb trace
$crumbs_sep = ' <span class="bcsep">'.$sep.'</span> ';
$crumbs_sep = ' <span class="bcsep">' . $sep . '</span> ';
//render crumbs, highlight the last one
$out .= '<span class="bchead">'.$lang['breadcrumb'].'</span>';
$out .= '<span class="bchead">' . $lang['breadcrumb'] . '</span>';
$last = count($crumbs);
$i = 0;
foreach ($crumbs as $id => $name) {
$i++;
$out .= $crumbs_sep;
if ($i == $last) $out .= '<span class="curid">';
$out .= '<bdi>' . tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="'.$id.'"', true) . '</bdi>';
$out .= '<bdi>' . tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="' . $id . '"', true) . '</bdi>';
if ($i == $last) $out .= '</span>';
}
if ($return) return $out;
@ -834,15 +834,15 @@ function tpl_youarehere($sep = null, $return = false)
$parts = explode(':', $ID);
$count = count($parts);
$out .= '<span class="bchead">'.$lang['youarehere'].' </span>';
$out .= '<span class="bchead">' . $lang['youarehere'] . ' </span>';
// always print the startpage
$out .= '<span class="home">' . tpl_pagelink(':'.$conf['start'], null, true) . '</span>';
$out .= '<span class="home">' . tpl_pagelink(':' . $conf['start'], null, true) . '</span>';
// print intermediate namespace links
$part = '';
for ($i = 0; $i < $count - 1; $i++) {
$part .= $parts[$i].':';
$part .= $parts[$i] . ':';
$page = $part;
if ($page == $conf['start']) continue; // Skip startpage
@ -859,7 +859,7 @@ function tpl_youarehere($sep = null, $return = false)
return true;
}
}
$page = $part.$parts[$i];
$page = $part . $parts[$i];
if ($page == $conf['start']) {
if ($return) return $out;
echo $out;
@ -889,7 +889,7 @@ function tpl_userinfo()
global $INPUT;
if ($INPUT->server->str('REMOTE_USER')) {
echo $lang['loggedinas'].' '.userlink();
echo $lang['loggedinas'] . ' ' . userlink();
return true;
}
return false;
@ -919,9 +919,9 @@ function tpl_pageinfo($ret = false)
$fn = $INFO['filepath'];
if (!$conf['fullpath']) {
if ($INFO['rev']) {
$fn = str_replace($conf['olddir'].'/', '', $fn);
$fn = str_replace($conf['olddir'] . '/', '', $fn);
} else {
$fn = str_replace($conf['datadir'].'/', '', $fn);
$fn = str_replace($conf['datadir'] . '/', '', $fn);
}
}
$fn = utf8_decodeFN($fn);
@ -930,22 +930,22 @@ function tpl_pageinfo($ret = false)
// print it
if ($INFO['exists']) {
$out = '';
$out .= '<bdi>'.$fn.'</bdi>';
$out .= '<bdi>' . $fn . '</bdi>';
$out .= ' · ';
$out .= $lang['lastmod'];
$out .= ' ';
$out .= $date;
if ($INFO['editor']) {
$out .= ' '.$lang['by'].' ';
$out .= '<bdi>'.editorinfo($INFO['editor']).'</bdi>';
$out .= ' ' . $lang['by'] . ' ';
$out .= '<bdi>' . editorinfo($INFO['editor']) . '</bdi>';
} else {
$out .= ' ('.$lang['external_edit'].')';
$out .= ' (' . $lang['external_edit'] . ')';
}
if ($INFO['locked']) {
$out .= ' · ';
$out .= $lang['lockedby'];
$out .= ' ';
$out .= '<bdi>'.editorinfo($INFO['locked']).'</bdi>';
$out .= '<bdi>' . editorinfo($INFO['locked']) . '</bdi>';
}
if ($ret) {
return $out;
@ -1002,19 +1002,19 @@ function tpl_pagetitle($id = null, $ret = false)
case 'profile':
case 'register':
case 'resendpwd':
$page_title = $lang['btn_'.$ACT];
$page_title = $lang['btn_' . $ACT];
break;
// wiki functions
case 'search':
case 'index':
$page_title = $lang['btn_'.$ACT];
$page_title = $lang['btn_' . $ACT];
break;
// page functions
case 'edit':
case 'preview':
$page_title = "".$name;
$page_title = "" . $name;
break;
case 'revisions':
@ -1024,7 +1024,7 @@ function tpl_pagetitle($id = null, $ret = false)
case 'backlink':
case 'recent':
case 'subscribe':
$page_title = $name . ' - ' . $lang['btn_'.$ACT];
$page_title = $name . ' - ' . $lang['btn_' . $ACT];
break;
default: // SHOW and anything else not included
@ -1099,7 +1099,7 @@ function tpl_img_meta()
$label = $lang[$tag['langkey']];
if (!$label) $label = $tag['langkey'] . ':';
echo '<dt>'.$label.'</dt><dd>';
echo '<dt>' . $label . '</dt><dd>';
if ($tag['type'] == 'date') {
echo dformat($tag['value']);
} else {
@ -1184,8 +1184,8 @@ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null)
}
//prepare URLs
$url = ml($IMG, ['cache'=> $INPUT->str('cache'), 'rev'=>$REV], true, '&');
$src = ml($IMG, ['cache'=> $INPUT->str('cache'), 'rev'=>$REV, 'w'=> $w, 'h'=> $h], true, '&');
$url = ml($IMG, ['cache' => $INPUT->str('cache'), 'rev' => $REV], true, '&');
$src = ml($IMG, ['cache' => $INPUT->str('cache'), 'rev' => $REV, 'w' => $w, 'h' => $h], true, '&');
//prepare attributes
$alt = tpl_img_getTag('Simple.Title');
@ -1205,7 +1205,7 @@ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null)
}
$p['src'] = $src;
$data = ['url'=> ($link ? $url : null), 'params'=> $p];
$data = ['url' => ($link ? $url : null), 'params' => $p];
return Event::createAndTrigger('TPL_IMG_DISPLAY', $data, '_tpl_img_action', true);
}
@ -1220,8 +1220,8 @@ function _tpl_img_action($data)
global $lang;
$p = buildAttributes($data['params']);
if ($data['url']) echo '<a href="'.hsc($data['url']).'" title="'.$lang['mediaview'].'">';
echo '<img '.$p.'/>';
if ($data['url']) echo '<a href="' . hsc($data['url']) . '" title="' . $lang['mediaview'] . '">';
echo '<img ' . $p . '/>';
if ($data['url']) echo '</a>';
return true;
}
@ -1239,8 +1239,8 @@ function tpl_indexerWebBug()
global $ID;
$p = [];
$p['src'] = DOKU_BASE.'lib/exe/taskrunner.php?id='.rawurlencode($ID).
'&'.time();
$p['src'] = DOKU_BASE . 'lib/exe/taskrunner.php?id=' . rawurlencode($ID) .
'&' . time();
$p['width'] = 2; //no more 1x1 px image because we live in times of ad blockers...
$p['height'] = 1;
$p['alt'] = '';
@ -1290,7 +1290,7 @@ function tpl_getConf($id, $notset = false)
function tpl_loadConfig()
{
$file = tpl_incdir().'/conf/default.php';
$file = tpl_incdir() . '/conf/default.php';
$conf = [];
if (!file_exists($file)) return false;
@ -1361,14 +1361,14 @@ function tpl_locale_xhtml($id)
*/
function tpl_localeFN($id)
{
$path = tpl_incdir().'lang/';
$path = tpl_incdir() . 'lang/';
global $conf;
$file = DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt';
$file = DOKU_CONF . 'template_lang/' . $conf['template'] . '/' . $conf['lang'] . '/' . $id . '.txt';
if (!file_exists($file)) {
$file = $path.$conf['lang'].'/'.$id.'.txt';
$file = $path . $conf['lang'] . '/' . $id . '.txt';
if (!file_exists($file)) {
//fall back to english
$file = $path.'en/'.$id.'.txt';
$file = $path . 'en/' . $id . '.txt';
}
}
return $file;
@ -1425,7 +1425,7 @@ function tpl_mediaContent($fromajax = false, $sort = 'natural')
} elseif ($do == 'searchlist') {
media_searchlist($INPUT->str('q'), $NS, $AUTH);
} else {
msg('Unknown action '.hsc($do), -1);
msg('Unknown action ' . hsc($do), -1);
}
}
$evt->advise_after();
@ -1454,21 +1454,21 @@ function tpl_mediaFileList()
if (!$opened_tab || !in_array($opened_tab, ['files', 'upload', 'search'])) $opened_tab = 'files';
if ($INPUT->str('mediado') == 'update') $opened_tab = 'upload';
echo '<h2 class="a11y">'.$lang['mediaselect'].'</h2>'.NL;
echo '<h2 class="a11y">' . $lang['mediaselect'] . '</h2>' . NL;
media_tabs_files($opened_tab);
echo '<div class="panelHeader">'.NL;
echo '<div class="panelHeader">' . NL;
echo '<h3>';
$tabTitle = $NS ?: '['.$lang['mediaroot'].']';
printf($lang['media_'.$opened_tab], '<strong>'.hsc($tabTitle).'</strong>');
echo '</h3>'.NL;
$tabTitle = $NS ?: '[' . $lang['mediaroot'] . ']';
printf($lang['media_' . $opened_tab], '<strong>' . hsc($tabTitle) . '</strong>');
echo '</h3>' . NL;
if ($opened_tab === 'search' || $opened_tab === 'files') {
media_tab_files_options();
}
echo '</div>'.NL;
echo '</div>' . NL;
echo '<div class="panelContent">'.NL;
echo '<div class="panelContent">' . NL;
if ($opened_tab == 'files') {
media_tab_files($NS, $AUTH, $JUMPTO);
} elseif ($opened_tab == 'upload') {
@ -1476,7 +1476,7 @@ function tpl_mediaFileList()
} elseif ($opened_tab == 'search') {
media_tab_search($NS, $AUTH);
}
echo '</div>'.NL;
echo '</div>' . NL;
}
/**
@ -1526,20 +1526,25 @@ function tpl_mediaFileDetails($image, $rev)
echo '<div class="panelHeader"><h3>';
[$ext] = mimetype($image, false);
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$class = 'select mediafile mf_'.$class;
$class = 'select mediafile mf_' . $class;
$attributes = $rev ? ['rev' => $rev] : [];
$tabTitle = '<strong><a href="'.ml($image, $attributes).'" class="'.$class.'" title="'.$lang['mediaview'].'">'.
$image.'</a>'.'</strong>';
$tabTitle = sprintf(
'<strong><a href="%s" class="%s" title="%s">%s</a></strong>',
ml($image, $attributes),
$class,
$lang['mediaview'],
$image
);
if ($opened_tab === 'view' && $rev) {
printf($lang['media_viewold'], $tabTitle, dformat($rev));
} else {
printf($lang['media_'.$opened_tab], $tabTitle);
printf($lang['media_' . $opened_tab], $tabTitle);
}
echo '</h3></div>'.NL;
echo '</h3></div>' . NL;
echo '<div class="panelContent">'.NL;
echo '<div class="panelContent">' . NL;
if ($opened_tab == 'view') {
media_tab_view($image, $ns, null, $rev);
@ -1549,7 +1554,7 @@ function tpl_mediaFileDetails($image, $rev)
media_tab_history($image, $ns);
}
echo '</div>'.NL;
echo '</div>' . NL;
}
/**
@ -1603,22 +1608,22 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap =
if (!$conf['license']) return '';
if (!is_array($license[$conf['license']])) return '';
$lic = $license[$conf['license']];
$target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : '';
$target = ($conf['target']['extern']) ? ' target="' . $conf['target']['extern'] . '"' : '';
$out = '';
if ($wrap) $out .= '<div class="license">';
if ($img) {
$src = license_img($img);
if ($src) {
$out .= '<a href="'.$lic['url'].'" rel="license"'.$target;
$out .= '><img src="'.DOKU_BASE.$src.'" alt="'.$lic['name'].'" /></a>';
$out .= '<a href="' . $lic['url'] . '" rel="license"' . $target;
$out .= '><img src="' . DOKU_BASE . $src . '" alt="' . $lic['name'] . '" /></a>';
if (!$imgonly) $out .= ' ';
}
}
if (!$imgonly) {
$out .= $lang['license'].' ';
$out .= '<bdi><a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target;
$out .= '>'.$lic['name'].'</a></bdi>';
$out .= $lang['license'] . ' ';
$out .= '<bdi><a href="' . $lic['url'] . '" rel="license" class="urlextern"' . $target;
$out .= '>' . $lic['name'] . '</a></bdi>';
}
if ($wrap) $out .= '</div>';
@ -1665,7 +1670,7 @@ function tpl_include_page($pageid, $print = true, $propagate = false, $useacl =
*/
function tpl_subscribe()
{
dbg_deprecated(Subscribe::class .'::show()');
dbg_deprecated(Subscribe::class . '::show()');
(new Subscribe())->show();
}
@ -1708,7 +1713,7 @@ function tpl_getMediaFile($search, $abs = false, &$imginfo = null, $fallback = t
$file = mediaFN($img);
$ismedia = true;
} else {
$file = tpl_incdir().$img;
$file = tpl_incdir() . $img;
$ismedia = false;
}
@ -1735,8 +1740,8 @@ function tpl_getMediaFile($search, $abs = false, &$imginfo = null, $fallback = t
if ($ismedia) {
$url = ml($img, '', true, '', $abs);
} else {
$url = tpl_basedir().$img;
if ($abs) $url = DOKU_URL.substr($url, strlen(DOKU_REL));
$url = tpl_basedir() . $img;
if ($abs) $url = DOKU_URL . substr($url, strlen(DOKU_REL));
}
return $url;
@ -1775,7 +1780,7 @@ function tpl_includeFile($file)
}
// still here? try the template dir
$file = tpl_incdir().$file;
$file = tpl_incdir() . $file;
if (file_exists($file)) {
include($file);
}
@ -1798,16 +1803,16 @@ function tpl_favicon($types = ['favicon'])
switch ($type) {
case 'favicon':
$look = [':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico'];
$return .= '<link rel="shortcut icon" href="'.tpl_getMediaFile($look).'" />'.NL;
$return .= '<link rel="shortcut icon" href="' . tpl_getMediaFile($look) . '" />' . NL;
break;
case 'mobile':
$look = [':wiki:apple-touch-icon.png', ':apple-touch-icon.png', 'images/apple-touch-icon.png'];
$return .= '<link rel="apple-touch-icon" href="'.tpl_getMediaFile($look).'" />'.NL;
$return .= '<link rel="apple-touch-icon" href="' . tpl_getMediaFile($look) . '" />' . NL;
break;
case 'generic':
// ideal world solution, which doesn't work in any browser yet
$look = [':wiki:favicon.svg', ':favicon.svg', 'images/favicon.svg'];
$return .= '<link rel="icon" href="'.tpl_getMediaFile($look).'" type="image/svg+xml" />'.NL;
$return .= '<link rel="icon" href="' . tpl_getMediaFile($look) . '" type="image/svg+xml" />' . NL;
break;
}
}
@ -1824,7 +1829,7 @@ function tpl_media()
{
global $NS, $IMG, $JUMPTO, $REV, $lang, $fullscreen, $INPUT;
$fullscreen = true;
require_once DOKU_INC.'lib/exe/mediamanager.php';
require_once DOKU_INC . 'lib/exe/mediamanager.php';
$rev = '';
$image = cleanID($INPUT->str('image'));
@ -1832,31 +1837,31 @@ function tpl_media()
if (isset($JUMPTO)) $image = $JUMPTO;
if (isset($REV) && !$JUMPTO) $rev = $REV;
echo '<div id="mediamanager__page">'.NL;
echo '<h1>'.$lang['btn_media'].'</h1>'.NL;
echo '<div id="mediamanager__page">' . NL;
echo '<h1>' . $lang['btn_media'] . '</h1>' . NL;
html_msgarea();
echo '<div class="panel namespaces">'.NL;
echo '<h2>'.$lang['namespaces'].'</h2>'.NL;
echo '<div class="panel namespaces">' . NL;
echo '<h2>' . $lang['namespaces'] . '</h2>' . NL;
echo '<div class="panelHeader">';
echo $lang['media_namespaces'];
echo '</div>'.NL;
echo '</div>' . NL;
echo '<div class="panelContent" id="media__tree">'.NL;
echo '<div class="panelContent" id="media__tree">' . NL;
media_nstree($NS);
echo '</div>'.NL;
echo '</div>'.NL;
echo '</div>' . NL;
echo '</div>' . NL;
echo '<div class="panel filelist">'.NL;
echo '<div class="panel filelist">' . NL;
tpl_mediaFileList();
echo '</div>'.NL;
echo '</div>' . NL;
echo '<div class="panel file">'.NL;
echo '<h2 class="a11y">'.$lang['media_file'].'</h2>'.NL;
echo '<div class="panel file">' . NL;
echo '<h2 class="a11y">' . $lang['media_file'] . '</h2>' . NL;
tpl_mediaFileDetails($image, $rev);
echo '</div>'.NL;
echo '</div>' . NL;
echo '</div>'.NL;
echo '</div>' . NL;
}
/**
@ -1874,8 +1879,8 @@ function tpl_classes()
$classes = [
'dokuwiki',
'mode_'.$ACT,
'tpl_'.$conf['template'],
'mode_' . $ACT,
'tpl_' . $conf['template'],
$INPUT->server->bool('REMOTE_USER') ? 'loggedIn' : '',
(isset($INFO['exists']) && $INFO['exists']) ? '' : 'notFound',
($ID == $conf['start']) ? 'home' : ''

View File

@ -159,7 +159,7 @@ function toolbar_JSdefines($varname)
'icon' => 'linkextern.png',
'open' => '[[',
'close' => ']]',
'sample' => 'http://example.com|'.$lang['qb_extlink'],
'sample' => 'http://example.com|' . $lang['qb_extlink'],
'block' => false
],
[
@ -193,7 +193,7 @@ function toolbar_JSdefines($varname)
'icon' => 'image.png',
'url' => 'lib/exe/mediamanager.php?ns=',
'name' => 'mediaselect',
'options'=> 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes',
'options' => 'width=750,height=500,left=20,top=20,scrollbars=yes,resizable=yes',
'block' => false
],
[
@ -201,7 +201,7 @@ function toolbar_JSdefines($varname)
'title' => $lang['qb_smileys'],
'icon' => 'smiley.png',
'list' => getSmileys(),
'icobase'=> 'smileys',
'icobase' => 'smileys',
'block' => false
],
[
@ -247,7 +247,7 @@ function toolbar_JSdefines($varname)
unset($evt);
// use JSON to build the JavaScript array
echo "var $varname = ".json_encode($menu, JSON_THROW_ON_ERROR).";\n";
echo "var $varname = " . json_encode($menu, JSON_THROW_ON_ERROR) . ";\n";
}
/**

View File

@ -31,27 +31,27 @@
<?php
$fi_list = ''; $fi_list32 = '';
foreach (glob('*.png') as $img) {
$fi_list .= '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> ';
$fi_list .= '<img src="' . $img . '" alt="' . $img . '" title="' . $img . '" /> ';
}
foreach (glob('32x32/*.png') as $img) {
$fi_list32 .= '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> ';
$fi_list32 .= '<img src="' . $img . '" alt="' . $img . '" title="' . $img . '" /> ';
}
echo '<div class="white box">
'.$fi_list.'
' . $fi_list . '
</div>
<div class="black box">
'.$fi_list.'
' . $fi_list . '
</div>
<br style="clear: left" />
<div class="white box">
'.$fi_list32.'
' . $fi_list32 . '
</div>
<div class="black box">
'.$fi_list32;
' . $fi_list32;
?>
</div>

View File

@ -15,7 +15,7 @@
<body>
<?php
foreach (glob('*.svg') as $img) {
echo '<img src="'.$img.'" alt="'.$img.'" width="32" height="32" title="'.$img.'" /> ';
echo '<img src="' . $img . '" alt="' . $img . '" width="32" height="32" title="' . $img . '" /> ';
}
?>
</body>

View File

@ -31,21 +31,21 @@
<?php
$smi_list = '';
foreach (glob('*.svg') as $img) {
$smi_list .= '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> ';
$smi_list .= '<img src="' . $img . '" alt="' . $img . '" title="' . $img . '" /> ';
}
if (is_dir('local')) {
$smi_list .= '<hr />';
foreach (glob('local/*.svg') as $img) {
$smi_list .= '<img src="'.$img.'" alt="'.$img.'" title="'.$img.'" /> ';
$smi_list .= '<img src="' . $img . '" alt="' . $img . '" title="' . $img . '" /> ';
}
}
echo '<div class="white box">
'.$smi_list.'
' . $smi_list . '
</div>
<div class="black box">
'.$smi_list;
' . $smi_list;
?>
</div>

View File

@ -1,4 +1,5 @@
<?php
use dokuwiki\Extension\AdminPlugin;
use dokuwiki\Utf8\Sort;
@ -86,7 +87,7 @@ class admin_plugin_acl extends AdminPlugin
// user or group choosen?
$who = trim($INPUT->str('acl_w'));
if ($INPUT->str('acl_t') == '__g__' && $who) {
$this->who = '@'.ltrim($auth->cleanGroup($who), '@');
$this->who = '@' . ltrim($auth->cleanGroup($who), '@');
} elseif ($INPUT->str('acl_t') == '__u__' && $who) {
$this->who = ltrim($who, '@');
if ($this->who != '%USER%' && $this->who != '%GROUP%') { #keep wildcard as is
@ -94,8 +95,8 @@ class admin_plugin_acl extends AdminPlugin
}
} elseif (
$INPUT->str('acl_t') &&
$INPUT->str('acl_t') != '__u__' &&
$INPUT->str('acl_t') != '__g__'
$INPUT->str('acl_t') != '__u__' &&
$INPUT->str('acl_t') != '__g__'
) {
$this->who = $INPUT->str('acl_t');
} elseif ($who) {
@ -111,7 +112,7 @@ class admin_plugin_acl extends AdminPlugin
if ($this->ns == '*') {
$scope = '*';
} else {
$scope = $this->ns.':*';
$scope = $this->ns . ':*';
}
} else {
$scope = $ID;
@ -146,9 +147,9 @@ class admin_plugin_acl extends AdminPlugin
// re-add all rules
foreach ($acl as $where => $opt) {
foreach ($opt as $who => $perm) {
if ($who[0]=='@') {
if ($who[0] == '@') {
if ($who != '@ALL') {
$who = '@'.ltrim($auth->cleanGroup($who), '@');
$who = '@' . ltrim($auth->cleanGroup($who), '@');
}
} elseif ($who != '%USER%' && $who != '%GROUP%') { #keep wildcard as is
$who = $auth->cleanUser($who);
@ -180,31 +181,31 @@ class admin_plugin_acl extends AdminPlugin
*/
public function html()
{
echo '<div id="acl_manager">'.NL;
echo '<h1>'.$this->getLang('admin_acl').'</h1>'.NL;
echo '<div class="level1">'.NL;
echo '<div id="acl_manager">';
echo '<h1>' . $this->getLang('admin_acl') . '</h1>';
echo '<div class="level1">';
echo '<div id="acl__tree">'.NL;
echo '<div id="acl__tree">';
$this->makeExplorer();
echo '</div>'.NL;
echo '</div>';
echo '<div id="acl__detail">'.NL;
echo '<div id="acl__detail">';
$this->printDetail();
echo '</div>'.NL;
echo '</div>'.NL;
echo '</div>';
echo '</div>';
echo '<div class="clearer"></div>';
echo '<h2>'.$this->getLang('current').'</h2>'.NL;
echo '<div class="level2">'.NL;
echo '<h2>' . $this->getLang('current') . '</h2>';
echo '<div class="level2">';
$this->printAclTable();
echo '</div>'.NL;
echo '</div>';
echo '<div class="footnotes"><div class="fn">'.NL;
echo '<sup><a id="fn__1" class="fn_bot" href="#fnt__1">1)</a></sup>'.NL;
echo '<div class="content">'.$this->getLang('p_include').'</div>';
echo '<div class="footnotes"><div class="fn">';
echo '<sup><a id="fn__1" class="fn_bot" href="#fnt__1">1)</a></sup>';
echo '<div class="content">' . $this->getLang('p_include') . '</div>';
echo '</div></div>';
echo '</div>'.NL;
echo '</div>';
}
/**
@ -214,7 +215,7 @@ class admin_plugin_acl extends AdminPlugin
*/
protected function getLinkOptions($addopts = null)
{
$opts = ['do'=>'admin', 'page'=>'acl'];
$opts = ['do' => 'admin', 'page' => 'acl'];
if ($this->ns) $opts['ns'] = $this->ns;
if ($this->who) $opts['acl_w'] = $this->who;
@ -233,14 +234,14 @@ class admin_plugin_acl extends AdminPlugin
global $ID;
global $lang;
$ns = $this->ns;
$ns = $this->ns;
if (empty($ns)) {
$ns = dirname(str_replace(':', '/', $ID));
if ($ns == '.') $ns ='';
if ($ns == '.') $ns = '';
} elseif ($ns == '*') {
$ns ='';
$ns = '';
}
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$ns = utf8_encodeFN(str_replace(':', '/', $ns));
$data = $this->makeTree($ns);
@ -249,8 +250,8 @@ class admin_plugin_acl extends AdminPlugin
'level' => 0,
'id' => '*',
'type' => 'd',
'open' =>'true',
'label' => '['.$lang['mediaroot'].']'
'open' => 'true',
'label' => '[' . $lang['mediaroot'] . ']'
]);
echo html_buildlist(
@ -285,8 +286,8 @@ class admin_plugin_acl extends AdminPlugin
// combine by sorting and removing duplicates
usort($data, [$this, 'treeSort']);
$count = count($data);
if ($count>0) for ($i=1; $i<$count; $i++) {
if ($data[$i-1]['id'] == $data[$i]['id'] && $data[$i-1]['type'] == $data[$i]['type']) {
if ($count > 0) for ($i = 1; $i < $count; $i++) {
if ($data[$i - 1]['id'] == $data[$i]['id'] && $data[$i - 1]['type'] == $data[$i]['type']) {
unset($data[$i]);
$i++; // duplicate found, next $i can't be a duplicate, so skip forward one
}
@ -347,25 +348,28 @@ class admin_plugin_acl extends AdminPlugin
{
global $ID;
echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">';
echo '<div id="acl__user">';
echo $this->getLang('acl_perms').' ';
$inl = $this->makeSelect();
echo '<input type="text" name="acl_w" class="edit" value="'.(($inl)?'':hsc(ltrim($this->who, '@'))).'" />'.NL;
echo '<button type="submit">'.$this->getLang('btn_select').'</button>'.NL;
echo '</div>'.NL;
echo $this->getLang('acl_perms') . ' ';
$inl = $this->makeSelect();
echo sprintf(
'<input type="text" name="acl_w" class="edit" value="%s" />',
($inl) ? '' : hsc(ltrim($this->who, '@'))
);
echo '<button type="submit">' . $this->getLang('btn_select') . '</button>';
echo '</div>';
echo '<div id="acl__info">';
$this->printInfo();
echo '</div>';
echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
echo '<input type="hidden" name="do" value="admin" />'.NL;
echo '<input type="hidden" name="page" value="acl" />'.NL;
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
echo '</div></form>'.NL;
echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />';
echo '<input type="hidden" name="id" value="' . hsc($ID) . '" />';
echo '<input type="hidden" name="do" value="admin" />';
echo '<input type="hidden" name="page" value="acl" />';
echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
echo '</div></form>';
}
/**
@ -408,18 +412,18 @@ class admin_plugin_acl extends AdminPlugin
echo '<fieldset>';
if (is_null($current)) {
echo '<legend>'.$this->getLang('acl_new').'</legend>';
echo '<legend>' . $this->getLang('acl_new') . '</legend>';
} else {
echo '<legend>'.$this->getLang('acl_mod').'</legend>';
echo '<legend>' . $this->getLang('acl_mod') . '</legend>';
}
echo $this->makeCheckboxes($current, empty($this->ns), 'acl');
if (is_null($current)) {
echo '<button type="submit" name="cmd[save]">'.$lang['btn_save'].'</button>'.NL;
echo '<button type="submit" name="cmd[save]">' . $lang['btn_save'] . '</button>';
} else {
echo '<button type="submit" name="cmd[save]">'.$lang['btn_update'].'</button>'.NL;
echo '<button type="submit" name="cmd[del]">'.$lang['btn_delete'].'</button>'.NL;
echo '<button type="submit" name="cmd[save]">' . $lang['btn_update'] . '</button>';
echo '<button type="submit" name="cmd[del]">' . $lang['btn_delete'] . '</button>';
}
echo '</fieldset>';
@ -436,14 +440,14 @@ class admin_plugin_acl extends AdminPlugin
global $auth;
$who = $this->who;
$ns = $this->ns;
$ns = $this->ns;
// prepare where to check
if ($ns) {
if ($ns == '*') {
$check='*';
$check = '*';
} else {
$check=$ns.':*';
$check = $ns . ':*';
}
} else {
$check = $ID;
@ -451,7 +455,7 @@ class admin_plugin_acl extends AdminPlugin
// prepare who to check
if ($who[0] == '@') {
$user = '';
$user = '';
$groups = [ltrim($who, '@')];
} else {
$user = $who;
@ -498,9 +502,9 @@ class admin_plugin_acl extends AdminPlugin
// add note if admin
if ($perm == AUTH_ADMIN) {
echo '<p>'.$this->getLang('p_isadmin').'</p>';
echo '<p>' . $this->getLang('p_isadmin') . '</p>';
} elseif (is_null($current)) {
echo '<p>'.$this->getLang('p_inherited').'</p>';
echo '<p>' . $this->getLang('p_inherited') . '</p>';
}
}
@ -519,36 +523,36 @@ class admin_plugin_acl extends AdminPlugin
if (!empty($item['label'])) {
$base = $item['label'];
} else {
$base = ':'.$item['id'];
$base = substr($base, strrpos($base, ':')+1);
$base = ':' . $item['id'];
$base = substr($base, strrpos($base, ':') + 1);
}
// highlight?
if (($item['type']== $this->current_item['type'] && $item['id'] == $this->current_item['id'])) {
if (($item['type'] == $this->current_item['type'] && $item['id'] == $this->current_item['id'])) {
$cl = ' cur';
} else {
$cl = '';
}
// namespace or page?
if ($item['type']=='d') {
if ($item['type'] == 'd') {
if ($item['open']) {
$img = DOKU_BASE.'lib/images/minus.gif';
$alt = '';
$img = DOKU_BASE . 'lib/images/minus.gif';
$alt = '';
} else {
$img = DOKU_BASE.'lib/images/plus.gif';
$alt = '+';
$img = DOKU_BASE . 'lib/images/plus.gif';
$alt = '+';
}
$ret .= '<img src="'.$img.'" alt="'.$alt.'" />';
$ret .= '<a href="'.
wl('', $this->getLinkOptions(['ns'=> $item['id'], 'sectok'=>getSecurityToken()])).
'" class="idx_dir'.$cl.'">';
$ret .= '<img src="' . $img . '" alt="' . $alt . '" />';
$ret .= '<a href="' .
wl('', $this->getLinkOptions(['ns' => $item['id'], 'sectok' => getSecurityToken()])) .
'" class="idx_dir' . $cl . '">';
$ret .= $base;
$ret .= '</a>';
} else {
$ret .= '<a href="'.
wl('', $this->getLinkOptions(['id'=> $item['id'], 'ns'=>'', 'sectok'=>getSecurityToken()])).
'" class="wikilink1'.$cl.'">';
$ret .= '<a href="' .
wl('', $this->getLinkOptions(['id' => $item['id'], 'ns' => '', 'sectok' => getSecurityToken()])) .
'" class="wikilink1' . $cl . '">';
$ret .= noNS($item['id']);
$ret .= '</a>';
}
@ -564,7 +568,7 @@ class admin_plugin_acl extends AdminPlugin
public function makeListItem($item)
{
return '<li class="level' . $item['level'] . ' ' .
($item['open'] ? 'open' : 'closed') . '">';
($item['open'] ? 'open' : 'closed') . '">';
}
@ -577,12 +581,12 @@ class admin_plugin_acl extends AdminPlugin
{
global $AUTH_ACL;
global $conf;
$acl_config=[];
$acl_config = [];
$usersgroups = [];
// get special users and groups
$this->specials[] = '@ALL';
$this->specials[] = '@'.$conf['defaultgroup'];
$this->specials[] = '@' . $conf['defaultgroup'];
if ($conf['manager'] != '!!not set!!') {
$this->specials = array_merge(
$this->specials,
@ -633,51 +637,51 @@ class admin_plugin_acl extends AdminPlugin
global $lang;
global $ID;
echo '<form action="'.wl().'" method="post" accept-charset="utf-8"><div class="no">'.NL;
echo '<form action="' . wl() . '" method="post" accept-charset="utf-8"><div class="no">';
if ($this->ns) {
echo '<input type="hidden" name="ns" value="'.hsc($this->ns).'" />'.NL;
echo '<input type="hidden" name="ns" value="' . hsc($this->ns) . '" />';
} else {
echo '<input type="hidden" name="id" value="'.hsc($ID).'" />'.NL;
echo '<input type="hidden" name="id" value="' . hsc($ID) . '" />';
}
echo '<input type="hidden" name="acl_w" value="'.hsc($this->who).'" />'.NL;
echo '<input type="hidden" name="do" value="admin" />'.NL;
echo '<input type="hidden" name="page" value="acl" />'.NL;
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'.NL;
echo '<input type="hidden" name="acl_w" value="' . hsc($this->who) . '" />';
echo '<input type="hidden" name="do" value="admin" />';
echo '<input type="hidden" name="page" value="acl" />';
echo '<input type="hidden" name="sectok" value="' . getSecurityToken() . '" />';
echo '<div class="table">';
echo '<table class="inline">';
echo '<tr>';
echo '<th>'.$this->getLang('where').'</th>';
echo '<th>'.$this->getLang('who').'</th>';
echo '<th>'.$this->getLang('perm').'<sup><a id="fnt__1" class="fn_top" href="#fn__1">1)</a></sup></th>';
echo '<th>'.$lang['btn_delete'].'</th>';
echo '<th>' . $this->getLang('where') . '</th>';
echo '<th>' . $this->getLang('who') . '</th>';
echo '<th>' . $this->getLang('perm') . '<sup><a id="fnt__1" class="fn_top" href="#fn__1">1)</a></sup></th>';
echo '<th>' . $lang['btn_delete'] . '</th>';
echo '</tr>';
foreach ($this->acl as $where => $set) {
foreach ($set as $who => $perm) {
echo '<tr>';
echo '<td>';
if (substr($where, -1) == '*') {
echo '<span class="aclns">'.hsc($where).'</span>';
echo '<span class="aclns">' . hsc($where) . '</span>';
$ispage = false;
} else {
echo '<span class="aclpage">'.hsc($where).'</span>';
echo '<span class="aclpage">' . hsc($where) . '</span>';
$ispage = true;
}
echo '</td>';
echo '<td>';
if ($who[0] == '@') {
echo '<span class="aclgroup">'.hsc($who).'</span>';
echo '<span class="aclgroup">' . hsc($who) . '</span>';
} else {
echo '<span class="acluser">'.hsc($who).'</span>';
echo '<span class="acluser">' . hsc($who) . '</span>';
}
echo '</td>';
echo '<td>';
echo $this->makeCheckboxes($perm, $ispage, 'acl['.$where.']['.$who.']');
echo $this->makeCheckboxes($perm, $ispage, 'acl[' . $where . '][' . $who . ']');
echo '</td>';
echo '<td class="check">';
echo '<input type="checkbox" name="del['.hsc($where).'][]" value="'.hsc($who).'" />';
echo '<input type="checkbox" name="del[' . hsc($where) . '][]" value="' . hsc($who) . '" />';
echo '</td>';
echo '</tr>';
}
@ -685,12 +689,12 @@ class admin_plugin_acl extends AdminPlugin
echo '<tr>';
echo '<th class="action" colspan="4">';
echo '<button type="submit" name="cmd[update]">'.$lang['btn_update'].'</button>';
echo '<button type="submit" name="cmd[update]">' . $lang['btn_update'] . '</button>';
echo '</th>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo '</div></form>'.NL;
echo '</div></form>';
}
/**
@ -706,7 +710,7 @@ class admin_plugin_acl extends AdminPlugin
if ($this->ns == '*') {
$check = '*';
} else {
$check = $this->ns.':*';
$check = $this->ns . ':*';
}
} else {
$check = $ID;
@ -752,7 +756,7 @@ class admin_plugin_acl extends AdminPlugin
global $config_cascade;
$acl_user = auth_nameencode($acl_user, true);
$acl_pattern = '^'.preg_quote($acl_scope, '/').'[ \t]+'.$acl_user.'[ \t]+[0-8].*$';
$acl_pattern = '^' . preg_quote($acl_scope, '/') . '[ \t]+' . $acl_user . '[ \t]+[0-8].*$';
return io_deleteFromFile($config_cascade['acl']['default'], "/$acl_pattern/", true);
}
@ -777,13 +781,13 @@ class admin_plugin_acl extends AdminPlugin
//general checkbox attributes
$atts = [
'type' => 'radio',
'id' => 'pbox'.$label,
'name' => $name,
'type' => 'radio',
'id' => 'pbox' . $label,
'name' => $name,
'value' => $perm
];
//dynamic attributes
if (!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
if (!is_null($setperm) && $setperm == $perm) $atts['checked'] = 'checked';
if ($ispage && $perm > AUTH_EDIT) {
$atts['disabled'] = 'disabled';
$class = ' class="disabled"';
@ -792,10 +796,10 @@ class admin_plugin_acl extends AdminPlugin
}
//build code
$ret .= '<label for="pbox'.$label.'"'.$class.'>';
$ret .= '<input '.buildAttributes($atts).' />&#160;';
$ret .= $this->getLang('acl_perm'.$perm);
$ret .= '</label>'.NL;
$ret .= '<label for="pbox' . $label . '"' . $class . '>';
$ret .= '<input ' . buildAttributes($atts) . ' />&#160;';
$ret .= $this->getLang('acl_perm' . $perm);
$ret .= '</label>';
}
return $ret;
}
@ -825,46 +829,46 @@ class admin_plugin_acl extends AdminPlugin
$inlist = true;
}
echo '<select name="acl_t" class="edit">'.NL;
echo ' <option value="__g__" class="aclgroup"'.$gsel.'>'.$this->getLang('acl_group').'</option>'.NL;
echo ' <option value="__u__" class="acluser"'.$usel.'>'.$this->getLang('acl_user').'</option>'.NL;
echo '<select name="acl_t" class="edit">';
echo ' <option value="__g__" class="aclgroup"' . $gsel . '>' . $this->getLang('acl_group') . '</option>';
echo ' <option value="__u__" class="acluser"' . $usel . '>' . $this->getLang('acl_user') . '</option>';
if (!empty($this->specials)) {
echo ' <optgroup label="&#160;">'.NL;
echo ' <optgroup label="&#160;">';
foreach ($this->specials as $ug) {
if ($ug == $this->who) {
$sel = ' selected="selected"';
$sel = ' selected="selected"';
$inlist = true;
} else {
$sel = '';
}
if ($ug[0] == '@') {
echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
echo ' <option value="' . hsc($ug) . '" class="aclgroup"' . $sel . '>' . hsc($ug) . '</option>';
} else {
echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
echo ' <option value="' . hsc($ug) . '" class="acluser"' . $sel . '>' . hsc($ug) . '</option>';
}
}
echo ' </optgroup>'.NL;
echo ' </optgroup>';
}
if (!empty($this->usersgroups)) {
echo ' <optgroup label="&#160;">'.NL;
echo ' <optgroup label="&#160;">';
foreach ($this->usersgroups as $ug) {
if ($ug == $this->who) {
$sel = ' selected="selected"';
$sel = ' selected="selected"';
$inlist = true;
} else {
$sel = '';
}
if ($ug[0] == '@') {
echo ' <option value="'.hsc($ug).'" class="aclgroup"'.$sel.'>'.hsc($ug).'</option>'.NL;
echo ' <option value="' . hsc($ug) . '" class="aclgroup"' . $sel . '>' . hsc($ug) . '</option>';
} else {
echo ' <option value="'.hsc($ug).'" class="acluser"'.$sel.'>'.hsc($ug).'</option>'.NL;
echo ' <option value="' . hsc($ug) . '" class="acluser"' . $sel . '>' . hsc($ug) . '</option>';
}
}
echo ' </optgroup>'.NL;
echo ' </optgroup>';
}
echo '</select>'.NL;
echo '</select>';
return $inlist;
}
}

View File

@ -42,7 +42,7 @@ class action_plugin_authad extends ActionPlugin
$usr = $auth->cleanUser($event->data['user']);
$dom = $auth->getUserDomain($usr);
if (!$dom) {
$usr = "$usr@".$INPUT->str('dom');
$usr = "$usr@" . $INPUT->str('dom');
}
$INPUT->post->set('u', $usr);
$event->data['user'] = $usr;
@ -85,7 +85,7 @@ class action_plugin_authad extends ActionPlugin
}
// add locate domain selector just after the username input box
$element = $form->addDropdown('dom', $domains, $this->getLang('domain'), $pos +1);
$element = $form->addDropdown('dom', $domains, $this->getLang('domain'), $pos + 1);
$element->addClass('block');
}
}

View File

@ -79,8 +79,8 @@ class auth_plugin_authad extends AuthPlugin
global $INPUT;
parent::__construct();
require_once(DOKU_PLUGIN.'authad/adLDAP/adLDAP.php');
require_once(DOKU_PLUGIN.'authad/adLDAP/classes/adLDAPUtils.php');
require_once(DOKU_PLUGIN . 'authad/adLDAP/adLDAP.php');
require_once(DOKU_PLUGIN . 'authad/adLDAP/classes/adLDAPUtils.php');
// we load the config early to modify it a bit here
$this->loadConfig();
@ -268,7 +268,7 @@ class auth_plugin_authad extends AuthPlugin
$expiry = $adldap->user()->passwordExpiry($user);
if (is_array($expiry)) {
$info['expiresat'] = $expiry['expiryts'];
$info['expiresin'] = round(($info['expiresat'] - time())/(24*60*60));
$info['expiresin'] = round(($info['expiresat'] - time()) / (24 * 60 * 60));
// if this is the current user, warn him (once per request only)
if (
@ -278,8 +278,8 @@ class auth_plugin_authad extends AuthPlugin
) {
$msg = sprintf($this->getLang('authpwdexpire'), $info['expiresin']);
if ($this->canDo('modPass')) {
$url = wl($ID, ['do'=> 'profile']);
$msg .= ' <a href="'.$url.'">'.$lang['btn_profile'].'</a>';
$url = wl($ID, ['do' => 'profile']);
$msg .= ' <a href="' . $url . '">' . $lang['btn_profile'] . '</a>';
}
msg($msg);
$this->msgshown = true;
@ -412,15 +412,15 @@ class auth_plugin_authad extends AuthPlugin
$usermanager = plugin_load("admin", "usermanager", false);
$usermanager->setLastdisabled(true);
if (!isset($this->grpsusers[$this->filterToString($filter)])) {
$this->fillGroupUserArray($filter, $usermanager->getStart() + 3*$usermanager->getPagesize());
$this->fillGroupUserArray($filter, $usermanager->getStart() + 3 * $usermanager->getPagesize());
} elseif (
count($this->grpsusers[$this->filterToString($filter)]) <
$usermanager->getStart() + 3*$usermanager->getPagesize()
$usermanager->getStart() + 3 * $usermanager->getPagesize()
) {
$this->fillGroupUserArray(
$filter,
$usermanager->getStart() +
3*$usermanager->getPagesize() -
3 * $usermanager->getPagesize() -
count($this->grpsusers[$this->filterToString($filter)])
);
}
@ -481,7 +481,7 @@ class auth_plugin_authad extends AuthPlugin
$actualstart = 0;
}
$i=0;
$i = 0;
$count = 0;
$this->constructPattern($filter);
foreach ($this->users as $user => &$info) {
@ -546,7 +546,7 @@ class auth_plugin_authad extends AuthPlugin
$usermanager->setLastdisabled(true);
if (
!isset($this->grpsusers[$this->filterToString($filter)]) ||
count($this->grpsusers[$this->filterToString($filter)]) < ($start+$limit)
count($this->grpsusers[$this->filterToString($filter)]) < ($start + $limit)
) {
if (!isset($this->grpsusers[$this->filterToString($filter)])) {
$this->grpsusers[$this->filterToString($filter)] = [];
@ -554,7 +554,7 @@ class auth_plugin_authad extends AuthPlugin
$this->fillGroupUserArray(
$filter,
$start+$limit - count($this->grpsusers[$this->filterToString($filter)]) +1
$start + $limit - count($this->grpsusers[$this->filterToString($filter)]) + 1
);
}
if (!$this->grpsusers[$this->filterToString($filter)]) return [];
@ -590,7 +590,7 @@ class auth_plugin_authad extends AuthPlugin
try {
$return = $adldap->user()->password($this->getUserName($user), $changes['pass']);
} catch (adLDAPException $e) {
if ($this->conf['debug']) msg('AD Auth: '.$e->getMessage(), -1);
if ($this->conf['debug']) msg('AD Auth: ' . $e->getMessage(), -1);
$return = false;
}
if (!$return) msg($this->getLang('passchangefail'), -1);
@ -612,7 +612,7 @@ class auth_plugin_authad extends AuthPlugin
try {
$return &= $adldap->user()->modify($this->getUserName($user), $adchanges);
} catch (adLDAPException $e) {
if ($this->conf['debug']) msg('AD Auth: '.$e->getMessage(), -1);
if ($this->conf['debug']) msg('AD Auth: ' . $e->getMessage(), -1);
$return = false;
}
if (!$return) msg($this->getLang('userchangefail'), -1);
@ -646,7 +646,7 @@ class auth_plugin_authad extends AuthPlugin
return $this->adldap[$domain];
} catch (Exception $e) {
if ($this->conf['debug']) {
msg('AD Auth: '.$e->getMessage(), -1);
msg('AD Auth: ' . $e->getMessage(), -1);
}
$this->success = false;
$this->adldap[$domain] = null;
@ -797,7 +797,7 @@ class auth_plugin_authad extends AuthPlugin
{
$this->pattern = [];
foreach ($filter as $item => $pattern) {
$this->pattern[$item] = '/'.str_replace('/', '\/', $pattern).'/i'; // allow regex characters
$this->pattern[$item] = '/' . str_replace('/', '\/', $pattern) . '/i'; // allow regex characters
}
}
}

View File

@ -11,7 +11,7 @@ $meta['real_primarygroup'] = array('onoff','_caution' => 'danger');
$meta['use_ssl'] = array('onoff','_caution' => 'danger');
$meta['use_tls'] = array('onoff','_caution' => 'danger');
$meta['debug'] = array('onoff','_caution' => 'security');
$meta['expirywarn'] = array('numeric', '_min'=>0,'_caution' => 'danger');
$meta['expirywarn'] = array('numeric', '_min' => 0,'_caution' => 'danger');
$meta['additional'] = array('string','_caution' => 'danger');
$meta['update_name'] = array('onoff','_caution' => 'danger');
$meta['update_mail'] = array('onoff','_caution' => 'danger');

View File

@ -10,7 +10,7 @@ $meta['starttls'] = array('onoff','_caution' => 'danger');
$meta['referrals'] = array('multichoice','_choices' => array(-1,0,1),'_caution' => 'danger');
$meta['deref'] = array('multichoice','_choices' => array(0,1,2,3),'_caution' => 'danger');
$meta['binddn'] = array('string','_caution' => 'danger');
$meta['bindpw'] = array('password','_caution' => 'danger','_code'=>'base64');
$meta['bindpw'] = array('password','_caution' => 'danger','_code' => 'base64');
$meta['attributes'] = array('array');
//$meta['mapping']['name'] unsupported in config manager
//$meta['mapping']['grps'] unsupported in config manager

View File

@ -112,7 +112,7 @@ class auth_plugin_authplain extends AuthPlugin
$userline = [$user, $pass, $name, $mail, $groups];
$userline = str_replace('\\', '\\\\', $userline); // escape \ as \\
$userline = str_replace(':', '\\:', $userline); // escape : as \:
$userline = implode(':', $userline)."\n";
$userline = implode(':', $userline) . "\n";
return $userline;
}
@ -214,7 +214,7 @@ class auth_plugin_authplain extends AuthPlugin
$userinfo['grps']
);
if (!io_replaceInFile($config_cascade['plainauth.users']['default'], '/^'.$user.':/', $userline, true)) {
if (!io_replaceInFile($config_cascade['plainauth.users']['default'], '/^' . $user . ':/', $userline, true)) {
msg('There was an error modifying your user data. You may need to register again.', -1);
// FIXME, io functions should be fail-safe so existing data isn't lost
$ACT = 'register';
@ -253,7 +253,7 @@ class auth_plugin_authplain extends AuthPlugin
if ($deleted === []) return 0;
$pattern = '/^('.implode('|', $deleted).'):/';
$pattern = '/^(' . implode('|', $deleted) . '):/';
if (!io_deleteFromFile($config_cascade['plainauth.users']['default'], $pattern, true)) {
msg($this->getLang('writefail'), -1);
return 0;
@ -481,7 +481,7 @@ class auth_plugin_authplain extends AuthPlugin
{
$this->pattern = [];
foreach ($filter as $item => $pattern) {
$this->pattern[$item] = '/'.str_replace('/', '\/', $pattern).'/i'; // allow regex characters
$this->pattern[$item] = '/' . str_replace('/', '\/', $pattern) . '/i'; // allow regex characters
}
}
}

View File

@ -70,9 +70,9 @@ class action_plugin_extension extends ActionPlugin
$reverse = ($act == 'disable') ? 'enable' : 'disable';
$return = [
'state' => $act.'d', // isn't English wonderful? :-)
'state' => $act . 'd', // isn't English wonderful? :-)
'reverse' => $reverse,
'label' => $extension->getLang('btn_'.$reverse),
'label' => $extension->getLang('btn_' . $reverse),
];
header('Content-Type: application/json');

View File

@ -54,8 +54,8 @@ class admin_plugin_extension extends AdminPlugin
if (!$repository->hasAccess(!$INPUT->bool('purge'))) {
$url = $this->gui->tabURL('', ['purge' => 1], '&');
msg($this->getLang('repo_error').
' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1);
msg($this->getLang('repo_error') .
' [<a href="' . $url . '">' . $this->getLang('repo_retry') . '</a>]', -1);
}
if (!in_array('ssl', stream_get_transports())) {
@ -78,7 +78,7 @@ class admin_plugin_extension extends AdminPlugin
$installed = $extension->installOrUpdate();
foreach ($installed as $info) {
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
$info['base']
), 1);
}
@ -133,7 +133,7 @@ class admin_plugin_extension extends AdminPlugin
);
foreach ($installed as $info) {
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
$info['base']
), 1);
}
@ -142,7 +142,7 @@ class admin_plugin_extension extends AdminPlugin
$installed = $extension->installFromUpload('installfile', $INPUT->post->bool('overwrite'));
foreach ($installed as $info) {
msg(sprintf(
$this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
$this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
$info['base']
), 1);
}
@ -159,8 +159,8 @@ class admin_plugin_extension extends AdminPlugin
*/
public function html()
{
echo '<h1>'.$this->getLang('menu').'</h1>'.DOKU_LF;
echo '<div id="extension__manager">'.DOKU_LF;
echo '<h1>' . $this->getLang('menu') . '</h1>' . DOKU_LF;
echo '<div id="extension__manager">' . DOKU_LF;
$this->gui->tabNavigation();
@ -179,7 +179,7 @@ class admin_plugin_extension extends AdminPlugin
$this->gui->tabPlugins();
}
echo '</div>'.DOKU_LF;
echo '</div>' . DOKU_LF;
}
}

View File

@ -39,7 +39,7 @@ class helper_plugin_extension_extension extends Plugin
*/
public function __construct()
{
$this->tpllib = dirname(tpl_incdir()).'/';
$this->tpllib = dirname(tpl_incdir()) . '/';
}
/**
@ -118,7 +118,7 @@ class helper_plugin_extension_extension extends Plugin
public function isGitControlled()
{
if (!$this->isInstalled()) return false;
return file_exists($this->getInstallDir().'/.git');
return file_exists($this->getInstallDir() . '/.git');
}
/**
@ -324,8 +324,8 @@ class helper_plugin_extension_extension extends Plugin
public function getURL()
{
if (!empty($this->localInfo['url'])) return $this->localInfo['url'];
return 'https://www.dokuwiki.org/'.
($this->isTemplate() ? 'template' : 'plugin').':'.$this->getBase();
return 'https://www.dokuwiki.org/' .
($this->isTemplate() ? 'template' : 'plugin') . ':' . $this->getBase();
}
/**
@ -589,9 +589,9 @@ class helper_plugin_extension_extension extends Plugin
public function getInstallDir()
{
if ($this->isTemplate()) {
return $this->tpllib.$this->base;
return $this->tpllib . $this->base;
} else {
return DOKU_PLUGIN.$this->base;
return DOKU_PLUGIN . $this->base;
}
}
@ -604,7 +604,7 @@ class helper_plugin_extension_extension extends Plugin
{
if (!$this->isInstalled()) return 'none';
if (!empty($this->managerData)) return 'automatic';
if (is_dir($this->getInstallDir().'/.git')) return 'git';
if (is_dir($this->getInstallDir() . '/.git')) return 'git';
return 'manual';
}
@ -640,7 +640,7 @@ class helper_plugin_extension_extension extends Plugin
public function installFromUpload($field, $overwrite = true)
{
if ($_FILES[$field]['error']) {
throw new Exception($this->getLang('msg_upload_failed').' ('.$_FILES[$field]['error'].')');
throw new Exception($this->getLang('msg_upload_failed') . ' (' . $_FILES[$field]['error'] . ')');
}
$tmp = $this->mkTmpDir();
@ -773,28 +773,28 @@ class helper_plugin_extension_extension extends Plugin
protected function readLocalData()
{
if ($this->isTemplate()) {
$infopath = $this->getInstallDir().'/template.info.txt';
$infopath = $this->getInstallDir() . '/template.info.txt';
} else {
$infopath = $this->getInstallDir().'/plugin.info.txt';
$infopath = $this->getInstallDir() . '/plugin.info.txt';
}
if (is_readable($infopath)) {
$this->localInfo = confToHash($infopath);
} elseif (!$this->isTemplate() && $this->isEnabled()) {
$path = $this->getInstallDir().'/';
$path = $this->getInstallDir() . '/';
$plugin = null;
foreach (PluginController::PLUGIN_TYPES as $type) {
if (file_exists($path.$type.'.php')) {
if (file_exists($path . $type . '.php')) {
$plugin = plugin_load($type, $this->base);
if ($plugin instanceof PluginInterface) break;
}
if ($dh = @opendir($path.$type.'/')) {
if ($dh = @opendir($path . $type . '/')) {
while (false !== ($cp = readdir($dh))) {
if ($cp == '.' || $cp == '..' || strtolower(substr($cp, -4)) != '.php') continue;
$plugin = plugin_load($type, $this->base.'_'.substr($cp, 0, -4));
$plugin = plugin_load($type, $this->base . '_' . substr($cp, 0, -4));
if ($plugin instanceof PluginInterface) break;
}
if ($plugin instanceof PluginInterface) break;
@ -845,7 +845,7 @@ class helper_plugin_extension_extension extends Plugin
*/
protected function readManagerData()
{
$managerpath = $this->getInstallDir().'/manager.dat';
$managerpath = $this->getInstallDir() . '/manager.dat';
if (is_readable($managerpath)) {
$file = @file($managerpath);
if (!empty($file)) {
@ -866,10 +866,10 @@ class helper_plugin_extension_extension extends Plugin
*/
protected function writeManagerData()
{
$managerpath = $this->getInstallDir().'/manager.dat';
$managerpath = $this->getInstallDir() . '/manager.dat';
$data = '';
foreach ($this->managerData as $k => $v) {
$data .= $k.'='.$v.DOKU_LF;
$data .= $k . '=' . $v . DOKU_LF;
}
io_saveFile($managerpath, $data);
}
@ -971,15 +971,15 @@ class helper_plugin_extension_extension extends Plugin
}
// download
if (!$file = $this->downloadToFile($url, $tmp.'/', $file)) {
if (!$file = $this->downloadToFile($url, $tmp . '/', $file)) {
io_rmdir($tmp, true);
throw new Exception(sprintf(
$this->getLang('error_download'),
'<bdi>'.hsc($url).'</bdi>'
'<bdi>' . hsc($url) . '</bdi>'
));
}
return $tmp.'/'.$file;
return $tmp . '/' . $file;
}
/**
@ -999,18 +999,18 @@ class helper_plugin_extension_extension extends Plugin
}
// add default base folder if specified to handle case where zip doesn't contain this
if ($base && !@mkdir($tmp.'/'.$base)) {
if ($base && !@mkdir($tmp . '/' . $base)) {
throw new Exception($this->getLang('error_dircreate'));
}
// decompress
$this->decompress($file, "$tmp/".$base);
$this->decompress($file, "$tmp/" . $base);
// search $tmp/$base for the folder(s) that has been created
// move the folder(s) to lib/..
$result = ['old'=>[], 'new'=>[]];
$result = ['old' => [], 'new' => []];
$default = ($this->isTemplate() ? 'template' : 'plugin');
if (!$this->findFolders($result, $tmp.'/'.$base, $default)) {
if (!$this->findFolders($result, $tmp . '/' . $base, $default)) {
throw new Exception($this->getLang('error_findfolder'));
}
@ -1046,7 +1046,7 @@ class helper_plugin_extension_extension extends Plugin
}
// check to make sure we aren't overwriting anything
$target = $target_base_dir.$item['base'];
$target = $target_base_dir . $item['base'];
if (!$overwrite && file_exists($target)) {
// this info message is not being exposed via exception,
// so that it's not interrupting the installation
@ -1061,7 +1061,7 @@ class helper_plugin_extension_extension extends Plugin
// return info
$id = $item['base'];
if ($item['type'] == 'template') {
$id = 'template:'.$id;
$id = 'template:' . $id;
}
$installed_extensions[$id] = [
'base' => $item['base'],
@ -1070,8 +1070,8 @@ class helper_plugin_extension_extension extends Plugin
];
} else {
throw new Exception(sprintf(
$this->getLang('error_copy').DOKU_LF,
'<bdi>'.$item['base'].'</bdi>'
$this->getLang('error_copy') . DOKU_LF,
'<bdi>' . $item['base'] . '</bdi>'
));
}
}
@ -1191,7 +1191,7 @@ class helper_plugin_extension_extension extends Plugin
$tar->open($file);
$tar->extract($target);
} catch (ArchiveIOException $e) {
throw new Exception($this->getLang('error_decompress').' '.$e->getMessage(), $e->getCode(), $e);
throw new Exception($this->getLang('error_decompress') . ' ' . $e->getMessage(), $e->getCode(), $e);
}
return true;
@ -1201,7 +1201,7 @@ class helper_plugin_extension_extension extends Plugin
$zip->open($file);
$zip->extract($target);
} catch (ArchiveIOException $e) {
throw new Exception($this->getLang('error_decompress').' '.$e->getMessage(), $e->getCode(), $e);
throw new Exception($this->getLang('error_decompress') . ' ' . $e->getMessage(), $e->getCode(), $e);
}
return true;
@ -1209,7 +1209,7 @@ class helper_plugin_extension_extension extends Plugin
// the only case when we don't get one of the recognized archive types is
// when the archive file can't be read
throw new Exception($this->getLang('error_decompress').' Couldn\'t read archive file');
throw new Exception($this->getLang('error_decompress') . ' Couldn\'t read archive file');
}
/**
@ -1286,7 +1286,7 @@ class helper_plugin_extension_extension extends Plugin
} else {
$extensiondir = DOKU_PLUGIN;
}
$extensiondir = $extensiondir . $extension['base'] .'/';
$extensiondir = $extensiondir . $extension['base'] . '/';
$definitionfile = $extensiondir . 'deleted.files';
if (!file_exists($definitionfile)) continue;

View File

@ -5,6 +5,7 @@
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Andreas Gohr <andi@splitbrain.org>
*/
use dokuwiki\Extension\Plugin;
use dokuwiki\Form\Form;
@ -45,8 +46,8 @@ class helper_plugin_extension_gui extends Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
]);
$list->startForm();
foreach ($pluginlist as $name) {
@ -68,7 +69,7 @@ class helper_plugin_extension_gui extends Plugin
echo '</div>';
// FIXME do we have a real way?
$tpllist = glob(DOKU_INC.'lib/tpl/*', GLOB_ONLYDIR);
$tpllist = glob(DOKU_INC . 'lib/tpl/*', GLOB_ONLYDIR);
$tpllist = array_map('basename', $tpllist);
sort($tpllist);
@ -78,8 +79,8 @@ class helper_plugin_extension_gui extends Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
]);
$list->startForm();
foreach ($tpllist as $name) {
@ -102,8 +103,8 @@ class helper_plugin_extension_gui extends Plugin
echo '</div>';
$form = new Form([
'action' => $this->tabURL('', [], '&'),
'class' => 'search',
'action' => $this->tabURL('', [], '&'),
'class' => 'search',
]);
$form->addTagOpen('div')->addClass('no');
$form->addTextInput('q', $this->getLang('search_for'))
@ -118,7 +119,7 @@ class helper_plugin_extension_gui extends Plugin
/* @var helper_plugin_extension_repository $repository FIXME should we use some gloabl instance? */
$repository = $this->loadHelper('extension_repository');
$result = $repository->search($INPUT->str('q'));
$result = $repository->search($INPUT->str('q'));
/* @var helper_plugin_extension_extension $extension */
$extension = $this->loadHelper('extension_extension');
@ -126,8 +127,8 @@ class helper_plugin_extension_gui extends Plugin
$list = $this->loadHelper('extension_list');
$form = new Form([
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
'action' => $this->tabURL('', [], '&'),
'id' => 'extension__list',
]);
$list->startForm();
if ($result) {
@ -154,9 +155,9 @@ class helper_plugin_extension_gui extends Plugin
echo '</div>';
$form = new Form([
'action' => $this->tabURL('', [], '&'),
'enctype' => 'multipart/form-data',
'class' => 'install',
'action' => $this->tabURL('', [], '&'),
'enctype' => 'multipart/form-data',
'class' => 'install',
]);
$form->addTagOpen('div')->addClass('no');
$form->addTextInput('installurl', $this->getLang('install_url'))
@ -191,7 +192,8 @@ class helper_plugin_extension_gui extends Plugin
} else {
$class = '';
}
echo '<li class="'.$tab.$class.'"><a href="'.$url.'">'.$this->getLang('tab_'.$tab).'</a></li>';
echo '<li class="' . $tab . $class . '"><a href="' . $url . '">' .
$this->getLang('tab_' . $tab) . '</a></li>';
}
echo '</ul>';
}
@ -213,10 +215,10 @@ class helper_plugin_extension_gui extends Plugin
/**
* Create an URL inside the extension manager
*
* @param string $tab tab to load, empty for current tab
* @param array $params associative array of parameter to set
* @param string $sep seperator to build the URL
* @param bool $absolute create absolute URLs?
* @param string $tab tab to load, empty for current tab
* @param array $params associative array of parameter to set
* @param string $sep seperator to build the URL
* @param bool $absolute create absolute URLs?
* @return string
*/
public function tabURL($tab = '', $params = [], $sep = '&', $absolute = false)
@ -226,9 +228,9 @@ class helper_plugin_extension_gui extends Plugin
if (!$tab) $tab = $this->currentTab();
$defaults = [
'do' => 'admin',
'do' => 'admin',
'page' => 'extension',
'tab' => $tab
'tab' => $tab
];
if ($tab == 'search') $defaults['q'] = $INPUT->str('q');

View File

@ -57,7 +57,7 @@ class helper_plugin_extension_list extends Plugin
*/
public function addHeader($id, $header, $level = 2)
{
$this->form .='<h'.$level.' id="'.$id.'">'.hsc($header).'</h'.$level.'>'.DOKU_LF;
$this->form .= '<h' . $level . ' id="' . $id . '">' . hsc($header) . '</h' . $level . '>' . DOKU_LF;
}
/**
@ -67,7 +67,7 @@ class helper_plugin_extension_list extends Plugin
*/
public function addParagraph($data)
{
$this->form .= '<p>'.hsc($data).'</p>'.DOKU_LF;
$this->form .= '<p>' . hsc($data) . '</p>' . DOKU_LF;
}
/**
@ -79,9 +79,9 @@ class helper_plugin_extension_list extends Plugin
{
$this->form .= '<div class="no">';
foreach ($data as $key => $value) {
$this->form .= '<input type="hidden" name="'.hsc($key).'" value="'.hsc($value).'" />';
$this->form .= '<input type="hidden" name="' . hsc($key) . '" value="' . hsc($value) . '" />';
}
$this->form .= '</div>'.DOKU_LF;
$this->form .= '</div>' . DOKU_LF;
}
/**
@ -98,7 +98,7 @@ class helper_plugin_extension_list extends Plugin
public function nothingFound()
{
global $lang;
$this->form .= '<li class="notfound">'.$lang['nothingfound'].'</li>';
$this->form .= '<li class="notfound">' . $lang['nothingfound'] . '</li>';
}
/**
@ -119,8 +119,8 @@ class helper_plugin_extension_list extends Plugin
*/
private function startRow(helper_plugin_extension_extension $extension)
{
$this->form .= '<li id="extensionplugin__'.hsc($extension->getID()).
'" class="'.$this->makeClass($extension).'">';
$this->form .= '<li id="extensionplugin__' . hsc($extension->getID()) .
'" class="' . $this->makeClass($extension) . '">';
}
/**
@ -130,7 +130,7 @@ class helper_plugin_extension_list extends Plugin
*/
private function populateColumn($class, $html)
{
$this->form .= '<div class="'.$class.' col">'.$html.'</div>'.DOKU_LF;
$this->form .= '<div class="' . $class . ' col">' . $html . '</div>' . DOKU_LF;
}
/**
@ -138,7 +138,7 @@ class helper_plugin_extension_list extends Plugin
*/
private function endRow()
{
$this->form .= '</li>'.DOKU_LF;
$this->form .= '</li>' . DOKU_LF;
}
/**
@ -166,8 +166,8 @@ class helper_plugin_extension_list extends Plugin
if ($linktype == 'extern' && $conf['relnofollow']) {
$param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
}
$html = ' <a '. buildAttributes($param, true).'>'.
$this->getLang('homepage_link').'</a>';
$html = ' <a ' . buildAttributes($param, true) . '>' .
$this->getLang('homepage_link') . '</a>';
return $html;
}
@ -181,12 +181,12 @@ class helper_plugin_extension_list extends Plugin
{
$class = ($extension->isTemplate()) ? 'template' : 'plugin';
if ($extension->isInstalled()) {
$class.=' installed';
$class.= ($extension->isEnabled()) ? ' enabled':' disabled';
$class .= ' installed';
$class .= ($extension->isEnabled()) ? ' enabled' : ' disabled';
if ($extension->updateAvailable()) $class .= ' updatable';
}
if (!$extension->canModify()) $class.= ' notselect';
if ($extension->isProtected()) $class.= ' protected';
if (!$extension->canModify()) $class .= ' notselect';
if ($extension->isProtected()) $class .= ' protected';
//if($this->showinfo) $class.= ' showinfo';
return $class;
}
@ -202,17 +202,17 @@ class helper_plugin_extension_list extends Plugin
if ($extension->getAuthor()) {
$mailid = $extension->getEmailID();
if ($mailid) {
$url = $this->gui->tabURL('search', ['q' => 'authorid:'.$mailid]);
$html = '<a href="'.$url.'" class="author" title="'.$this->getLang('author_hint').'" >'.
'<img src="//www.gravatar.com/avatar/'.$mailid.
'?s=20&amp;d=mm" width="20" height="20" alt="" /> '.
hsc($extension->getAuthor()).'</a>';
$url = $this->gui->tabURL('search', ['q' => 'authorid:' . $mailid]);
$html = '<a href="' . $url . '" class="author" title="' . $this->getLang('author_hint') . '" >' .
'<img src="//www.gravatar.com/avatar/' . $mailid .
'?s=20&amp;d=mm" width="20" height="20" alt="" /> ' .
hsc($extension->getAuthor()) . '</a>';
} else {
$html = '<span class="author">'.hsc($extension->getAuthor()).'</span>';
$html = '<span class="author">' . hsc($extension->getAuthor()) . '</span>';
}
$html = '<bdi>'.$html.'</bdi>';
$html = '<bdi>' . $html . '</bdi>';
} else {
$html = '<em class="author">'.$this->getLang('unknown_author').'</em>'.DOKU_LF;
$html = '<em class="author">' . $this->getLang('unknown_author') . '</em>' . DOKU_LF;
}
return $html;
}
@ -234,17 +234,17 @@ class helper_plugin_extension_list extends Plugin
$thumb = str_replace('http://www.dokuwiki.org', '//www.dokuwiki.org', $thumb);
$title = sprintf($this->getLang('screenshot'), hsc($extension->getDisplayName()));
$img = '<a href="'.hsc($screen).'" target="_blank" class="extension_screenshot">'.
'<img alt="'.$title.'" width="120" height="70" src="'.hsc($thumb).'" />'.
$img = '<a href="' . hsc($screen) . '" target="_blank" class="extension_screenshot">' .
'<img alt="' . $title . '" width="120" height="70" src="' . hsc($thumb) . '" />' .
'</a>';
} elseif ($extension->isTemplate()) {
$img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
$img = '<img alt="" width="120" height="70" src="' . DOKU_BASE .
'lib/plugins/extension/images/template.png" />';
} else {
$img = '<img alt="" width="120" height="70" src="'.DOKU_BASE.
$img = '<img alt="" width="120" height="70" src="' . DOKU_BASE .
'lib/plugins/extension/images/plugin.png" />';
}
$html = '<div class="screenshot" >'.$img.'<span></span></div>'.DOKU_LF;
$html = '<div class="screenshot" >' . $img . '<span></span></div>' . DOKU_LF;
return $html;
}
@ -261,26 +261,26 @@ class helper_plugin_extension_list extends Plugin
$html .= '<h2>';
$html .= sprintf(
$this->getLang('extensionby'),
'<bdi>'.hsc($extension->getDisplayName()).'</bdi>',
'<bdi>' . hsc($extension->getDisplayName()) . '</bdi>',
$this->makeAuthor($extension)
);
$html .= '</h2>'.DOKU_LF;
$html .= '</h2>' . DOKU_LF;
$html .= $this->makeScreenshot($extension);
$popularity = $extension->getPopularity();
if ($popularity !== false && !$extension->isBundled()) {
$popularityText = sprintf($this->getLang('popularity'), round($popularity*100, 2));
$html .= '<div class="popularity" title="'.$popularityText.'">'.
'<div style="width: '.($popularity * 100).'%;">'.
'<span class="a11y">'.$popularityText.'</span>'.
'</div></div>'.DOKU_LF;
$popularityText = sprintf($this->getLang('popularity'), round($popularity * 100, 2));
$html .= '<div class="popularity" title="' . $popularityText . '">' .
'<div style="width: ' . ($popularity * 100) . '%;">' .
'<span class="a11y">' . $popularityText . '</span>' .
'</div></div>' . DOKU_LF;
}
if ($extension->getDescription()) {
$html .= '<p><bdi>';
$html .= hsc($extension->getDescription()).' ';
$html .= '</bdi></p>'.DOKU_LF;
$html .= hsc($extension->getDescription()) . ' ';
$html .= '</bdi></p>' . DOKU_LF;
}
$html .= $this->makeLinkbar($extension);
@ -292,15 +292,15 @@ class helper_plugin_extension_list extends Plugin
$url = $this->gui->tabURL('', ['info' => $extension->getID()]);
$class = '';
}
$html .= ' <a href="'.$url.'#extensionplugin__'.$extension->getID().
'" class="info '.$class.'" title="'.$this->getLang('btn_info').
'" data-extid="'.$extension->getID().'">'.$this->getLang('btn_info').'</a>';
$html .= ' <a href="' . $url . '#extensionplugin__' . $extension->getID() .
'" class="info ' . $class . '" title="' . $this->getLang('btn_info') .
'" data-extid="' . $extension->getID() . '">' . $this->getLang('btn_info') . '</a>';
if ($showinfo) {
$html .= $this->makeInfo($extension);
}
$html .= $this->makeNoticeArea($extension);
$html .= '</div>'.DOKU_LF;
$html .= '</div>' . DOKU_LF;
return $html;
}
@ -333,24 +333,24 @@ class helper_plugin_extension_list extends Plugin
if ($conf['relnofollow']) {
$param['rel'] = implode(' ', [$param['rel'], 'ugc nofollow']);
}
$html .= ' <a '.buildAttributes($param, true).'>'.
$this->getLang('bugs_features').'</a>';
$html .= ' <a ' . buildAttributes($param, true) . '>' .
$this->getLang('bugs_features') . '</a>';
}
if ($extension->getTags()) {
$first = true;
$html .= ' <span class="tags">'.$this->getLang('tags').' ';
$html .= ' <span class="tags">' . $this->getLang('tags') . ' ';
foreach ($extension->getTags() as $tag) {
if (!$first) {
$html .= ', ';
} else {
$first = false;
}
$url = $this->gui->tabURL('search', ['q' => 'tag:'.$tag]);
$html .= '<bdi><a href="'.$url.'">'.hsc($tag).'</a></bdi>';
$url = $this->gui->tabURL('search', ['q' => 'tag:' . $tag]);
$html .= '<bdi><a href="' . $url . '">' . hsc($tag) . '</a></bdi>';
}
$html .= '</span>';
}
$html .= '</div>'.DOKU_LF;
$html .= '</div>' . DOKU_LF;
return $html;
}
@ -382,18 +382,18 @@ class helper_plugin_extension_list extends Plugin
'</div>';
}
if (($securityissue = $extension->getSecurityIssue()) !== false) {
$html .= '<div class="msg error">'.
sprintf($this->getLang('security_issue'), '<bdi>'.hsc($securityissue).'</bdi>').
$html .= '<div class="msg error">' .
sprintf($this->getLang('security_issue'), '<bdi>' . hsc($securityissue) . '</bdi>') .
'</div>';
}
if (($securitywarning = $extension->getSecurityWarning()) !== false) {
$html .= '<div class="msg notify">'.
sprintf($this->getLang('security_warning'), '<bdi>'.hsc($securitywarning).'</bdi>').
$html .= '<div class="msg notify">' .
sprintf($this->getLang('security_warning'), '<bdi>' . hsc($securitywarning) . '</bdi>') .
'</div>';
}
if ($extension->updateAvailable()) {
$html .= '<div class="msg notify">'.
sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())).
$html .= '<div class="msg notify">' .
sprintf($this->getLang('update_available'), hsc($extension->getLastUpdate())) .
'</div>';
}
if ($extension->hasDownloadURLChanged()) {
@ -405,7 +405,7 @@ class helper_plugin_extension_list extends Plugin
) .
'</div>';
}
return $html.DOKU_LF;
return $html . DOKU_LF;
}
/**
@ -421,13 +421,13 @@ class helper_plugin_extension_list extends Plugin
$link = parse_url($url);
$base = $link['host'];
if (!empty($link['port'])) $base .= $base.':'.$link['port'];
if (!empty($link['port'])) $base .= $base . ':' . $link['port'];
$long = $link['path'];
if (!empty($link['query'])) $long .= $link['query'];
$name = shorten($base, $long, 55);
$html = '<a href="'.hsc($url).'" class="urlextern">'.hsc($name).'</a>';
$html = '<a href="' . hsc($url) . '" class="urlextern">' . hsc($name) . '</a>';
return $html;
}
@ -442,26 +442,26 @@ class helper_plugin_extension_list extends Plugin
$default = $this->getLang('unknown');
$html = '<dl class="details">';
$html .= '<dt>'.$this->getLang('status').'</dt>';
$html .= '<dd>'.$this->makeStatus($extension).'</dd>';
$html .= '<dt>' . $this->getLang('status') . '</dt>';
$html .= '<dd>' . $this->makeStatus($extension) . '</dd>';
if ($extension->getDonationURL()) {
$html .= '<dt>'.$this->getLang('donate').'</dt>';
$html .= '<dt>' . $this->getLang('donate') . '</dt>';
$html .= '<dd>';
$html .= '<a href="'.$extension->getDonationURL().'" class="donate">'.
$this->getLang('donate_action').'</a>';
$html .= '<a href="' . $extension->getDonationURL() . '" class="donate">' .
$this->getLang('donate_action') . '</a>';
$html .= '</dd>';
}
if (!$extension->isBundled()) {
$html .= '<dt>'.$this->getLang('downloadurl').'</dt>';
$html .= '<dt>' . $this->getLang('downloadurl') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getDownloadURL()
? $this->shortlink($extension->getDownloadURL())
: $default);
$html .= '</bdi></dd>';
$html .= '<dt>'.$this->getLang('repository').'</dt>';
$html .= '<dt>' . $this->getLang('repository') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getSourcerepoURL()
? $this->shortlink($extension->getSourcerepoURL())
@ -471,13 +471,13 @@ class helper_plugin_extension_list extends Plugin
if ($extension->isInstalled()) {
if ($extension->getInstalledVersion()) {
$html .= '<dt>'.$this->getLang('installed_version').'</dt>';
$html .= '<dt>' . $this->getLang('installed_version') . '</dt>';
$html .= '<dd>';
$html .= hsc($extension->getInstalledVersion());
$html .= '</dd>';
}
if (!$extension->isBundled()) {
$html .= '<dt>'.$this->getLang('install_date').'</dt>';
$html .= '<dt>' . $this->getLang('install_date') . '</dt>';
$html .= '<dd>';
$html .= ($extension->getUpdateDate()
? hsc($extension->getUpdateDate())
@ -486,7 +486,7 @@ class helper_plugin_extension_list extends Plugin
}
}
if (!$extension->isInstalled() || $extension->updateAvailable()) {
$html .= '<dt>'.$this->getLang('available_version').'</dt>';
$html .= '<dt>' . $this->getLang('available_version') . '</dt>';
$html .= '<dd>';
$html .= ($extension->getLastUpdate()
? hsc($extension->getLastUpdate())
@ -494,7 +494,7 @@ class helper_plugin_extension_list extends Plugin
$html .= '</dd>';
}
$html .= '<dt>'.$this->getLang('provides').'</dt>';
$html .= '<dt>' . $this->getLang('provides') . '</dt>';
$html .= '<dd><bdi>';
$html .= ($extension->getTypes()
? hsc(implode(', ', $extension->getTypes()))
@ -502,35 +502,35 @@ class helper_plugin_extension_list extends Plugin
$html .= '</bdi></dd>';
if (!$extension->isBundled() && $extension->getCompatibleVersions()) {
$html .= '<dt>'.$this->getLang('compatible').'</dt>';
$html .= '<dt>' . $this->getLang('compatible') . '</dt>';
$html .= '<dd>';
foreach ($extension->getCompatibleVersions() as $date => $version) {
$html .= '<bdi>'.$version['label'].' ('.$date.')</bdi>, ';
$html .= '<bdi>' . $version['label'] . ' (' . $date . ')</bdi>, ';
}
$html = rtrim($html, ', ');
$html .= '</dd>';
}
if ($extension->getDependencies()) {
$html .= '<dt>'.$this->getLang('depends').'</dt>';
$html .= '<dt>' . $this->getLang('depends') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getDependencies());
$html .= '</dd>';
}
if ($extension->getSimilarExtensions()) {
$html .= '<dt>'.$this->getLang('similar').'</dt>';
$html .= '<dt>' . $this->getLang('similar') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getSimilarExtensions());
$html .= '</dd>';
}
if ($extension->getConflicts()) {
$html .= '<dt>'.$this->getLang('conflicts').'</dt>';
$html .= '<dt>' . $this->getLang('conflicts') . '</dt>';
$html .= '<dd>';
$html .= $this->makeLinkList($extension->getConflicts());
$html .= '</dd>';
}
$html .= '</dl>'.DOKU_LF;
$html .= '</dl>' . DOKU_LF;
return $html;
}
@ -544,9 +544,9 @@ class helper_plugin_extension_list extends Plugin
{
$html = '';
foreach ($ext as $link) {
$html .= '<bdi><a href="'.
$this->gui->tabURL('search', ['q'=>'ext:'.$link]).'">'.
hsc($link).'</a></bdi>, ';
$html .= '<bdi><a href="' .
$this->gui->tabURL('search', ['q' => 'ext:' . $link]) . '">' .
hsc($link) . '</a></bdi>, ';
}
return rtrim($html, ', ');
}
@ -576,7 +576,7 @@ class helper_plugin_extension_list extends Plugin
}
}
} else {
$errors .= '<p class="permerror">'.$this->getLang($canmod).'</p>';
$errors .= '<p class="permerror">' . $this->getLang($canmod) . '</p>';
}
if (!$extension->isProtected() && !$extension->isTemplate()) { // no enable/disable for templates
if ($extension->isEnabled()) {
@ -586,31 +586,31 @@ class helper_plugin_extension_list extends Plugin
}
}
if ($extension->isGitControlled()) {
$errors .= '<p class="permerror">'.$this->getLang('git').'</p>';
$errors .= '<p class="permerror">' . $this->getLang('git') . '</p>';
}
if (
$extension->isEnabled() &&
in_array('Auth', $extension->getTypes()) &&
$conf['authtype'] != $extension->getID()
) {
$errors .= '<p class="permerror">'.$this->getLang('auth').'</p>';
$errors .= '<p class="permerror">' . $this->getLang('auth') . '</p>';
}
} elseif (($canmod = $extension->canModify()) === true) {
if ($extension->getDownloadURL()) {
$html .= $this->makeAction('install', $extension);
}
} else {
$errors .= '<div class="permerror">'.$this->getLang($canmod).'</div>';
$errors .= '<div class="permerror">' . $this->getLang($canmod) . '</div>';
}
if (!$extension->isInstalled() && $extension->getDownloadURL()) {
$html .= ' <span class="version">'.$this->getLang('available_version').' ';
$html .= ' <span class="version">' . $this->getLang('available_version') . ' ';
$html .= ($extension->getLastUpdate()
? hsc($extension->getLastUpdate())
: $this->getLang('unknown')).'</span>';
: $this->getLang('unknown')) . '</span>';
}
return $html.' '.$errors.DOKU_LF;
return $html . ' ' . $errors . DOKU_LF;
}
/**
@ -625,14 +625,14 @@ class helper_plugin_extension_list extends Plugin
$title = '';
if ($action == 'install' || $action == 'reinstall') {
$title = 'title="'.hsc($extension->getDownloadURL()).'"';
$title = 'title="' . hsc($extension->getDownloadURL()) . '"';
}
$classes = 'button '.$action;
$name = 'fn['.$action.']['.hsc($extension->getID()).']';
$classes = 'button ' . $action;
$name = 'fn[' . $action . '][' . hsc($extension->getID()) . ']';
$html = '<button class="'.$classes.'" name="'.$name.'" type="submit" '.$title.'>'.
$this->getLang('btn_'.$action).'</button> ';
$html = '<button class="' . $classes . '" name="' . $name . '" type="submit" ' . $title . '>' .
$this->getLang('btn_' . $action) . '</button> ';
return $html;
}

View File

@ -33,7 +33,7 @@ class helper_plugin_extension_repository extends Plugin
$request_data = ['fmt' => 'php'];
$request_needed = false;
foreach ($list as $name) {
$cache = new Cache('##extension_manager##'.$name, '.repo');
$cache = new Cache('##extension_manager##' . $name, '.repo');
if (
!isset($this->loaded_extensions[$name]) &&
@ -52,7 +52,7 @@ class helper_plugin_extension_repository extends Plugin
if ($data !== false) {
$extensions = unserialize($data);
foreach ($extensions as $extension) {
$cache = new Cache('##extension_manager##'.$extension['plugin'], '.repo');
$cache = new Cache('##extension_manager##' . $extension['plugin'], '.repo');
$cache->storeCache(serialize($extension));
}
} else {
@ -73,10 +73,10 @@ class helper_plugin_extension_repository extends Plugin
if ($this->has_access === null) {
$cache = new Cache('##extension_manager###hasAccess', '.repo');
if (!$cache->useCache(['age' => 60*10, 'purge' => !$usecache])) {
if (!$cache->useCache(['age' => 60 * 10, 'purge' => !$usecache])) {
$httpclient = new DokuHTTPClient();
$httpclient->timeout = 5;
$data = $httpclient->get(self::EXTENSION_REPOSITORY_API.'?cmd=ping');
$data = $httpclient->get(self::EXTENSION_REPOSITORY_API . '?cmd=ping');
if ($data !== false) {
$this->has_access = true;
$cache->storeCache(1);
@ -99,7 +99,7 @@ class helper_plugin_extension_repository extends Plugin
*/
public function getData($name)
{
$cache = new Cache('##extension_manager##'.$name, '.repo');
$cache = new Cache('##extension_manager##' . $name, '.repo');
if (
!isset($this->loaded_extensions[$name]) &&
@ -108,7 +108,7 @@ class helper_plugin_extension_repository extends Plugin
) {
$this->loaded_extensions[$name] = true;
$httpclient = new DokuHTTPClient();
$data = $httpclient->get(self::EXTENSION_REPOSITORY_API.'?fmt=php&ext[]='.urlencode($name));
$data = $httpclient->get(self::EXTENSION_REPOSITORY_API . '?fmt=php&ext[]=' . urlencode($name));
if ($data !== false) {
$result = unserialize($data);
if (count($result)) {
@ -147,7 +147,7 @@ class helper_plugin_extension_repository extends Plugin
// store cache info for each extension
foreach ($result as $ext) {
$name = $ext['plugin'];
$cache = new Cache('##extension_manager##'.$name, '.repo');
$cache = new Cache('##extension_manager##' . $name, '.repo');
$cache->storeCache(serialize($ext));
$ids[] = $name;
}

View File

@ -64,6 +64,6 @@ class action_plugin_popularity extends ActionPlugin
protected function isTooEarlyToSubmit()
{
$lastSubmit = $this->helper->lastSentTime();
return $lastSubmit + 24*60*60*30 > time();
return $lastSubmit + 24 * 60 * 60 * 30 > time();
}
}

View File

@ -129,25 +129,25 @@ class admin_plugin_popularity extends AdminPlugin
$data = $this->helper->gatherAsString();
}
$form = '<form method="post" action="'. $url .'" accept-charset="utf-8">'
.'<fieldset style="width: 60%;">'
.'<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">'
.$data
.'</textarea><br />';
$form = '<form method="post" action="' . $url . '" accept-charset="utf-8">'
. '<fieldset style="width: 60%;">'
. '<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">'
. $data
. '</textarea><br />';
//If we submit via the server, we give the opportunity to suscribe to the autosubmission option
if ($submissionMode !== 'browser') {
$form .= '<label for="autosubmit">'
.'<input type="checkbox" name="autosubmit" id="autosubmit" '
.($this->helper->isAutosubmitEnabled() ? 'checked' : '' )
.'/> ' . $this->getLang('autosubmit') .'<br />'
.'</label>'
.'<input type="hidden" name="do" value="admin" />'
.'<input type="hidden" name="page" value="popularity" />';
. '<input type="checkbox" name="autosubmit" id="autosubmit" '
. ($this->helper->isAutosubmitEnabled() ? 'checked' : '' )
. '/> ' . $this->getLang('autosubmit') . '<br />'
. '</label>'
. '<input type="hidden" name="do" value="admin" />'
. '<input type="hidden" name="page" value="popularity" />';
}
$form .= '<button type="submit">'.$this->getLang('submit').'</button>'
.'</fieldset>'
.'</form>';
$form .= '<button type="submit">' . $this->getLang('submit') . '</button>'
. '</fieldset>'
. '</form>';
return $form;
}
}

View File

@ -39,9 +39,9 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
public function __construct()
{
global $conf;
$this->autosubmitFile = $conf['cachedir'].'/autosubmit.txt';
$this->autosubmitErrorFile = $conf['cachedir'].'/autosubmitError.txt';
$this->popularityLastSubmitFile = $conf['cachedir'].'/lastSubmitTime.txt';
$this->autosubmitFile = $conf['cachedir'] . '/autosubmit.txt';
$this->autosubmitErrorFile = $conf['cachedir'] . '/autosubmitError.txt';
$this->popularityLastSubmitFile = $conf['cachedir'] . '/lastSubmitTime.txt';
}
/**
@ -95,9 +95,9 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
$string = '';
foreach ($data as $key => $val) {
if (is_array($val)) foreach ($val as $v) {
$string .= hsc($key)."\t".hsc($v)."\n";
$string .= hsc($key) . "\t" . hsc($v) . "\n";
} else {
$string .= hsc($key)."\t".hsc($val)."\n";
$string .= hsc($key) . "\t" . hsc($val) . "\n";
}
}
return $string;
@ -152,7 +152,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of pages
$list = $this->initEmptySearchList();
search($list, $conf['datadir'], [$this, 'searchCountCallback'], ['all'=>false], '');
search($list, $conf['datadir'], [$this, 'searchCountCallback'], ['all' => false], '');
$data['page_count'] = $list['file_count'];
$data['page_size'] = $list['file_size'];
$data['page_biggest'] = $list['file_max'];
@ -165,7 +165,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of media
$list = $this->initEmptySearchList();
search($list, $conf['mediadir'], [$this, 'searchCountCallback'], ['all'=>true]);
search($list, $conf['mediadir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['media_count'] = $list['file_count'];
$data['media_size'] = $list['file_size'];
$data['media_biggest'] = $list['file_max'];
@ -177,7 +177,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of cache
$list = $this->initEmptySearchList();
search($list, $conf['cachedir'], [$this, 'searchCountCallback'], ['all'=>true]);
search($list, $conf['cachedir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['cache_count'] = $list['file_count'];
$data['cache_size'] = $list['file_size'];
$data['cache_biggest'] = $list['file_max'];
@ -187,7 +187,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of index
$list = $this->initEmptySearchList();
search($list, $conf['indexdir'], [$this, 'searchCountCallback'], ['all'=>true]);
search($list, $conf['indexdir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['index_count'] = $list['file_count'];
$data['index_size'] = $list['file_size'];
$data['index_biggest'] = $list['file_max'];
@ -197,7 +197,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of meta
$list = $this->initEmptySearchList();
search($list, $conf['metadir'], [$this, 'searchCountCallback'], ['all'=>true]);
search($list, $conf['metadir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['meta_count'] = $list['file_count'];
$data['meta_size'] = $list['file_size'];
$data['meta_biggest'] = $list['file_max'];
@ -207,7 +207,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
// number and size of attic
$list = $this->initEmptySearchList();
search($list, $conf['olddir'], [$this, 'searchCountCallback'], ['all'=>true]);
search($list, $conf['olddir'], [$this, 'searchCountCallback'], ['all' => true]);
$data['attic_count'] = $list['file_count'];
$data['attic_size'] = $list['file_size'];
$data['attic_biggest'] = $list['file_max'];
@ -222,13 +222,13 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
}
// calculate edits per day
$list = (array) @file($conf['metadir'].'/_dokuwiki.changes');
$list = (array) @file($conf['metadir'] . '/_dokuwiki.changes');
$count = count($list);
if ($count > 2) {
$first = (int) substr(array_shift($list), 0, 10);
$last = (int) substr(array_pop($list), 0, 10);
$dur = ($last - $first)/(60*60*24); // number of days in the changelog
$data['edits_per_day'] = $count/$dur;
$dur = ($last - $first) / (60 * 60 * 24); // number of days in the changelog
$data['edits_per_day'] = $count / $dur;
}
unset($list);
@ -297,8 +297,8 @@ class helper_plugin_popularity extends Dokuwiki_Plugin
//only search txt files if 'all' option not set
if ($opts['all'] || substr($file, -4) == '.txt') {
$size = filesize($base.'/'.$file);
$date = filemtime($base.'/'.$file);
$size = filesize($base . '/' . $file);
$date = filemtime($base . '/' . $file);
$data['file_count']++;
$data['file_size'] += $size;
if (!isset($data['file_min']) || $data['file_min'] > $size) $data['file_min'] = $size;

View File

@ -71,10 +71,10 @@ class admin_plugin_revert extends AdminPlugin
{
global $lang, $INPUT;
echo '<form action="" method="post"><div class="no">';
echo '<label>'.$this->getLang('filter').': </label>';
echo '<input type="text" name="filter" class="edit" value="'.hsc($INPUT->str('filter')).'" /> ';
echo '<button type="submit">'.$lang['btn_search'].'</button> ';
echo '<span>'.$this->getLang('note1').'</span>';
echo '<label>' . $this->getLang('filter') . ': </label>';
echo '<input type="text" name="filter" class="edit" value="' . hsc($INPUT->str('filter')) . '" /> ';
echo '<button type="submit">' . $lang['btn_search'] . '</button> ';
echo '<span>' . $this->getLang('note1') . '</span>';
echo '</div></form><br /><br />';
}
@ -84,7 +84,7 @@ class admin_plugin_revert extends AdminPlugin
protected function revertEdits($revert, $filter)
{
echo '<hr /><br />';
echo '<p>'.$this->getLang('revstart').'</p>';
echo '<p>' . $this->getLang('revstart') . '</p>';
echo '<ul>';
foreach ($revert as $id) {
@ -103,17 +103,17 @@ class admin_plugin_revert extends AdminPlugin
if ($data) {
saveWikiText($id, $data, 'old revision restored', false);
printf('<li><div class="li">'.$this->getLang('reverted').'</div></li>', $id, $REV);
printf('<li><div class="li">' . $this->getLang('reverted') . '</div></li>', $id, $REV);
} else {
saveWikiText($id, '', '', false);
printf('<li><div class="li">'.$this->getLang('removed').'</div></li>', $id);
printf('<li><div class="li">' . $this->getLang('removed') . '</div></li>', $id);
}
@set_time_limit(10);
flush();
}
echo '</ul>';
echo '<p>'.$this->getLang('revstop').'</p>';
echo '<p>' . $this->getLang('revstop') . '</p>';
}
/**
@ -125,7 +125,7 @@ class admin_plugin_revert extends AdminPlugin
global $lang;
echo '<hr /><br />';
echo '<form action="" method="post"><div class="no">';
echo '<input type="hidden" name="filter" value="'.hsc($filter).'" />';
echo '<input type="hidden" name="filter" value="' . hsc($filter) . '" />';
formSecurityToken();
$recents = getRecents(0, $this->max_lines);
@ -140,15 +140,15 @@ class admin_plugin_revert extends AdminPlugin
$cnt++;
$date = dformat($recent['date']);
echo ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
echo ($recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
echo '<div class="li">';
echo '<input type="checkbox" name="revert[]" value="'.hsc($recent['id']).
'" checked="checked" id="revert__'.$cnt.'" />';
echo ' <label for="revert__'.$cnt.'">'.$date.'</label> ';
echo '<input type="checkbox" name="revert[]" value="' . hsc($recent['id']) .
'" checked="checked" id="revert__' . $cnt . '" />';
echo ' <label for="revert__' . $cnt . '">' . $date . '</label> ';
echo '<a href="'.wl($recent['id'], "do=diff").'">';
echo '<a href="' . wl($recent['id'], "do=diff") . '">';
$p = [];
$p['src'] = DOKU_BASE.'lib/images/diff.png';
$p['src'] = DOKU_BASE . 'lib/images/diff.png';
$p['width'] = 15;
$p['height'] = 11;
$p['title'] = $lang['diff'];
@ -157,9 +157,9 @@ class admin_plugin_revert extends AdminPlugin
echo "<img $att />";
echo '</a> ';
echo '<a href="'.wl($recent['id'], "do=revisions").'">';
echo '<a href="' . wl($recent['id'], "do=revisions") . '">';
$p = [];
$p['src'] = DOKU_BASE.'lib/images/history.png';
$p['src'] = DOKU_BASE . 'lib/images/history.png';
$p['width'] = 12;
$p['height'] = 14;
$p['title'] = $lang['btn_revs'];
@ -168,11 +168,11 @@ class admin_plugin_revert extends AdminPlugin
echo "<img $att />";
echo '</a> ';
echo html_wikilink(':'.$recent['id'], (useHeading('navigation'))?null:$recent['id']);
echo ' '.htmlspecialchars($recent['sum']);
echo html_wikilink(':' . $recent['id'], (useHeading('navigation')) ? null : $recent['id']);
echo ' ' . htmlspecialchars($recent['sum']);
echo ' <span class="user">';
echo $recent['user'].' '.$recent['ip'];
echo $recent['user'] . ' ' . $recent['ip'];
echo '</span>';
echo '</div>';
@ -184,7 +184,7 @@ class admin_plugin_revert extends AdminPlugin
echo '</ul>';
echo '<p>';
echo '<button type="submit">'.$this->getLang('revert').'</button> ';
echo '<button type="submit">' . $this->getLang('revert') . '</button> ';
printf($this->getLang('note2'), hsc($filter));
echo '</p>';

View File

@ -29,24 +29,24 @@ class action_plugin_safefnrecode extends ActionPlugin
global $conf;
if ($conf['fnencode'] != 'safe') return;
if (!file_exists($conf['datadir'].'_safefn.recoded')) {
if (!file_exists($conf['datadir'] . '_safefn.recoded')) {
$this->recode($conf['datadir']);
touch($conf['datadir'].'_safefn.recoded');
touch($conf['datadir'] . '_safefn.recoded');
}
if (!file_exists($conf['olddir'].'_safefn.recoded')) {
if (!file_exists($conf['olddir'] . '_safefn.recoded')) {
$this->recode($conf['olddir']);
touch($conf['olddir'].'_safefn.recoded');
touch($conf['olddir'] . '_safefn.recoded');
}
if (!file_exists($conf['metadir'].'_safefn.recoded')) {
if (!file_exists($conf['metadir'] . '_safefn.recoded')) {
$this->recode($conf['metadir']);
touch($conf['metadir'].'_safefn.recoded');
touch($conf['metadir'] . '_safefn.recoded');
}
if (!file_exists($conf['mediadir'].'_safefn.recoded')) {
if (!file_exists($conf['mediadir'] . '_safefn.recoded')) {
$this->recode($conf['mediadir']);
touch($conf['mediadir'].'_safefn.recoded');
touch($conf['mediadir'] . '_safefn.recoded');
}
}

View File

@ -46,7 +46,7 @@ class action_plugin_styling extends ActionPlugin
$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();
}
}
}

View File

@ -1,6 +1,8 @@
<?php
use dokuwiki\Extension\AdminPlugin;
use dokuwiki\StyleUtils;
/**
* DokuWiki Plugin styling (Admin Component)
*
@ -37,7 +39,7 @@ class admin_plugin_styling extends AdminPlugin
$run = $INPUT->extract('run')->str('run');
if (!$run) return;
if (!checkSecurityToken()) return;
$run = 'run'.ucfirst($run);
$run = 'run' . ucfirst($run);
$this->$run();
}
@ -49,8 +51,8 @@ class admin_plugin_styling extends AdminPlugin
$class = 'nopopup';
if ($this->ispopup) $class = 'ispopup page';
echo '<div id="plugin__styling" class="'.$class.'">';
echo '<h1>'.$this->getLang('menu').'</h1>';
echo '<div id="plugin__styling" class="' . $class . '">';
echo '<h1>' . $this->getLang('menu') . '</h1>';
$this->form();
echo '</div>';
}
@ -64,21 +66,21 @@ class admin_plugin_styling extends AdminPlugin
global $ID;
$styleUtil = new StyleUtils($conf['template'], true, true);
$styleini = $styleUtil->cssStyleini();
$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, ['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>';
@ -88,27 +90,28 @@ class admin_plugin_styling extends AdminPlugin
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>';
@ -152,7 +155,7 @@ class admin_plugin_styling extends AdminPlugin
public function runPreview()
{
global $conf;
$ini = $conf['cachedir'].'/preview.ini';
$ini = $conf['cachedir'] . '/preview.ini';
io_saveFile($ini, $this->makeini());
}
@ -162,7 +165,7 @@ class admin_plugin_styling extends AdminPlugin
protected function runReset()
{
global $conf;
$ini = $conf['cachedir'].'/preview.ini';
$ini = $conf['cachedir'] . '/preview.ini';
io_saveFile($ini, '');
}
@ -197,7 +200,7 @@ class admin_plugin_styling extends AdminPlugin
$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;
@ -211,7 +214,7 @@ class admin_plugin_styling extends AdminPlugin
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);

View File

@ -46,7 +46,7 @@ if (!defined('DOKU_INC')) die();
<!-- detail start -->
<?php
if ($ERROR) :
echo '<h1>'.$ERROR.'</h1>';
echo '<h1>' . $ERROR . '</h1>';
else : ?>
<?php if ($REV) echo p_locale_xhtml('showrev');?>
<h1><?php echo nl2br(hsc(tpl_img_getTag('simple.title'))); ?></h1>
@ -57,14 +57,14 @@ if (!defined('DOKU_INC')) die();
<?php tpl_img_meta(); ?>
<dl>
<?php
echo '<dt>'.$lang['reference'].':</dt>';
echo '<dt>' . $lang['reference'] . ':</dt>';
$media_usage = ft_mediause($IMG, true);
if ($media_usage !== []) {
foreach ($media_usage as $path) {
echo '<dd>'.html_wikilink($path).'</dd>';
echo '<dd>' . html_wikilink($path) . '</dd>';
}
} else {
echo '<dd>'.$lang['nothingfound'].'</dd>';
echo '<dd>' . $lang['nothingfound'] . '</dd>';
}
?>
</dl>

View File

@ -11,7 +11,7 @@
if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */
$hasSidebar = page_findnearest($conf['sidebar']);
$showSidebar = $hasSidebar && ($ACT=='show');
$showSidebar = $hasSidebar && ($ACT == 'show');
?><!DOCTYPE html>
<html lang="<?php echo $conf['lang'] ?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
<head>

View File

@ -14,7 +14,7 @@ if (!defined('DOKU_INC')) die();
<div class="buttons">
<?php
tpl_license('button', true, false, false); // license button, no wrapper
$target = ($conf['target']['extern']) ? 'target="'.$conf['target']['extern'].'"' : '';
$target = ($conf['target']['extern']) ? 'target="' . $conf['target']['extern'] . '"' : '';
?>
<a href="https://www.dokuwiki.org/donate" title="Donate" <?php echo $target?>><img
src="<?php echo tpl_basedir(); ?>images/button-donate.gif" width="80" height="15" alt="Donate" /></a>

View File

@ -9,9 +9,9 @@
* @author Anika Henke <anika@selfthinker.org>
*/
// phpcs:disable PSR1.Files.SideEffects
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__.'/../../');
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
if (!defined('NOSESSION')) define('NOSESSION', 1);
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC . 'inc/init.php');
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
@ -50,21 +50,21 @@ $ini = $styleUtils->cssStyleini();
if (!empty($ini)) {
echo '<table>';
echo "<caption>".hsc($conf['template'])."'s style.ini</caption>";
echo "<caption>" . hsc($conf['template']) . "'s style.ini</caption>";
foreach ($ini['replacements'] as $key => $val) {
echo '<tr>';
echo '<td>'.hsc($key).'</td>';
echo '<td>'.hsc($val).'</td>';
echo '<td>' . hsc($key) . '</td>';
echo '<td>' . hsc($val) . '</td>';
echo '<td>';
if (preg_match('/^#[0-f]{3,6}$/i', $val)) {
echo '<div class="color" style="background-color:'.$val.';">&#160;</div>';
echo '<div class="color" style="background-color:' . $val . ';">&#160;</div>';
}
echo '</td>';
echo '</tr>';
}
echo '</table>';
} else {
echo "<p>Non-existent or invalid template or style.ini: <strong>".hsc($conf['template'])."</strong></p>";
echo "<p>Non-existent or invalid template or style.ini: <strong>" . hsc($conf['template']) . "</strong></p>";
}
?>
</body>