Skip to content

Commit

Permalink
Fix PHP errors
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Sep 27, 2023
1 parent 6a2be7f commit 1a50ad2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ public function getFiles($ns) {

$dir = utf8_encodeFN(str_replace(':','/',$ns));
$data = array();
search($data,$conf['mediadir'],array($this, 'search_media_and_namespaces'),
array('showmsg'=>false,'depth'=>1),$dir,1, false);
search($data, $conf['mediadir'], array($this, 'search_media_and_namespaces'),
array('showmsg' => false, 'depth' => 1), $dir, 1, false);

return array_map(array($this, 'fileInfo'), $data);
}
Expand All @@ -198,6 +198,8 @@ protected function fileInfo($item) {

$item['link'] = '<a href="'.wl($item['id']. ':start').'">' . $item['file'] . '</a>';
} else {
// consistent info needed for rendering
$item['isdir'] = false;
// Prepare fileicons
list($ext) = mimetype($item['file'],false);
$class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext);
Expand Down
12 changes: 7 additions & 5 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
* @author Szymon Olewniczak <dokuwiki@cosmocode.de>
*/

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
use dokuwiki\File\PageResolver;

class syntax_plugin_filelisting extends DokuWiki_Syntax_Plugin {
/**
Expand All @@ -16,12 +15,14 @@ class syntax_plugin_filelisting extends DokuWiki_Syntax_Plugin {
public function getType() {
return 'substition';
}

/**
* @return string Paragraph type
*/
public function getPType() {
return 'block';
}

/**
* @return int Sort order - Low numbers go before high numbers
*/
Expand Down Expand Up @@ -50,7 +51,7 @@ public function connectTo($mode) {
public function handle($match, $state, $pos, Doku_Handler $handler){
$param = substr($match, strlen('{{filelisting'), -strlen('}}'));
//remove '>' from the path
if(strlen($param) !== 0) $ns = substr($param, 1);
$ns = strlen($param) !== 0 ? $ns = substr($param, 1) : '';

return array($ns);
}
Expand All @@ -76,10 +77,11 @@ public function render($mode, Doku_Renderer $renderer, $data) {
$cur_ns = getNS($INFO['id']);

list($ns) = $data;
if(empty($ns)) {
if (empty($ns)) {
$ns = $cur_ns;
} else {
$ns = resolve_id($cur_ns, $ns);
$resolver = new PageResolver($INFO['id']);
$ns = $resolver->resolveId($ns);
}

/** @var helper_plugin_filelisting $hlp */
Expand Down

0 comments on commit 1a50ad2

Please sign in to comment.