Skip to content

🤖 Automatic code style fixes #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion GenericResolver.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

namespace dokuwiki\plugin\include;

use dokuwiki\File\Resolver;

/**
* Resolves ids without cleaning them.
*
* @package dokuwiki\plugin\include
*/
class GenericResolver extends Resolver {
class GenericResolver extends Resolver
{
}
181 changes: 95 additions & 86 deletions action.php

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

/**
* Options for the Include Plugin
*/

$conf['noheader'] = 0; // Don't display the header of the inserted section
$conf['firstseconly'] = 0; // limit entries on main blog page to first section
$conf['showtaglogos'] = 0; // display image for first tag
Expand Down
2 changes: 2 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* Metadata for configuration manager plugin
* Additions for the Include Plugin
*
* @author Esther Brunner <wikidesign@gmail.com>
*/

$meta['noheader'] = array('onoff');
$meta['firstseconly'] = array('onoff');
$meta['showtaglogos'] = array('onoff');
Expand Down
431 changes: 212 additions & 219 deletions helper.php

Large diffs are not rendered by default.

21 changes: 14 additions & 7 deletions syntax/closelastsecedit.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
<?php

use dokuwiki\Extension\SyntaxPlugin;

/**
* Include plugin (close last section edit)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Hamann <michael@content-space.de>
*/

class syntax_plugin_include_closelastsecedit extends DokuWiki_Syntax_Plugin {

function getType() {
class syntax_plugin_include_closelastsecedit extends SyntaxPlugin
{
public function getType()
{
return 'formatting';
}

function getSort() {
public function getSort()
{
return 50;
}

function handle($match, $state, $pos, Doku_Handler $handler) {
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
}

/**
* Finishes the last open section edit
*/
function render($mode, Doku_Renderer $renderer, $data) {
public function render($mode, Doku_Renderer $renderer, $data)
{
if ($mode == 'xhtml') {
/** @var Doku_Renderer_xhtml $renderer */
list($endpos) = $data;
[$endpos] = $data;
$renderer->finishSectionEdit($endpos);
return true;
}
Expand Down
25 changes: 16 additions & 9 deletions syntax/editbtn.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
<?php

use dokuwiki\Extension\SyntaxPlugin;

/**
* Include plugin (editbtn header component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Klier <chi@chimeric.de>
*/

class syntax_plugin_include_editbtn extends DokuWiki_Syntax_Plugin {

function getType() {
class syntax_plugin_include_editbtn extends SyntaxPlugin
{
public function getType()
{
return 'formatting';
}

function getSort() {

public function getSort()
{
return 50;
}

function handle($match, $state, $pos, Doku_Handler $handler) {
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
}

Expand All @@ -25,11 +31,12 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
*
* @author Michael Klier <chi@chimeric.de>
*/
function render($mode, Doku_Renderer $renderer, $data) {
list($title, $hid) = $data;
public function render($mode, Doku_Renderer $renderer, $data)
{
[$title, $hid] = $data;
if ($mode == 'xhtml') {
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
$renderer->startSectionEdit(0, array('target' => 'plugin_include_editbtn', 'name' => $title, 'hid' => $hid));
$renderer->startSectionEdit(0, ['target' => 'plugin_include_editbtn', 'name' => $title, 'hid' => $hid]);
} else {
$renderer->startSectionEdit(0, 'plugin_include_editbtn', $title);
}
Expand Down
45 changes: 23 additions & 22 deletions syntax/footer.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
<?php

use dokuwiki\Extension\SyntaxPlugin;

/**
* Include plugin (footer component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Michael Klier <chi@chimeric.de>
*/

class syntax_plugin_include_footer extends DokuWiki_Syntax_Plugin {

function getType() {
class syntax_plugin_include_footer extends SyntaxPlugin
{
public function getType()
{
return 'formatting';
}

function getSort() {
public function getSort()
{
return 300;
}

function handle($match, $state, $pos, Doku_Handler $handler) {
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
}

Expand All @@ -26,13 +32,14 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
* Code heavily copied from the header renderer from inc/parser/xhtml.php, just
* added an href parameter to the anchor tag linking to the wikilink.
*/
function render($mode, Doku_Renderer $renderer, $data) {
public function render($mode, Doku_Renderer $renderer, $data)
{

list($page, $sect, $sect_title, $flags, $redirect_id, $footer_lvl) = $data;
[$page, $sect, $sect_title, $flags, $redirect_id, $footer_lvl] = $data;

if ($mode == 'xhtml') {
$renderer->doc .= $this->html_footer($page, $sect, $sect_title, $flags, $footer_lvl, $renderer);
return true;
return true;
}
return false;
}
Expand All @@ -42,37 +49,31 @@ function render($mode, Doku_Renderer $renderer, $data) {
* @param $renderer Doku_Renderer_xhtml The (xhtml) renderer
* @return string The HTML code of the footer
*/
function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer) {
public function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer)
{
global $conf, $ID;

if(!$flags['footer']) return '';
if (!$flags['footer']) return '';

$meta = p_get_metadata($page);
$exists = page_exists($page);
$xhtml = array();
$xhtml = [];
// permalink
if ($flags['permalink']) {
$class = ($exists ? 'wikilink1' : 'wikilink2');
$url = ($sect) ? wl($page) . '#' . $sect : wl($page);
$name = ($sect) ? $sect_title : $page;
$title = ($sect) ? $page . '#' . $sect : $page;
if (!$title) $title = str_replace('_', ' ', noNS($page));
$link = array(
'url' => $url,
'title' => $title,
'name' => $name,
'target' => $conf['target']['wiki'],
'class' => $class . ' permalink',
'more' => 'rel="bookmark"',
);
$link = ['url' => $url, 'title' => $title, 'name' => $name, 'target' => $conf['target']['wiki'], 'class' => $class . ' permalink', 'more' => 'rel="bookmark"'];
$xhtml[] = $renderer->_formatLink($link);
}

// date
if ($flags['date'] && $exists) {
$date = $meta['date']['created'];
if ($date) {
$xhtml[] = '<abbr class="published" title="'.dformat($date, '%Y-%m-%dT%H:%M:%SZ').'">'
$xhtml[] = '<abbr class="published" title="' . dformat($date, '%Y-%m-%dT%H:%M:%SZ') . '">'
. dformat($date)
. '</abbr>';
}
Expand All @@ -82,7 +83,7 @@ function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer)
if ($flags['mdate'] && $exists) {
$mdate = $meta['date']['modified'];
if ($mdate) {
$xhtml[] = '<abbr class="published" title="'.dformat($mdate, '%Y-%m-%dT%H:%M:%SZ').'">'
$xhtml[] = '<abbr class="published" title="' . dformat($mdate, '%Y-%m-%dT%H:%M:%SZ') . '">'
. dformat($mdate)
. '</abbr>';
}
Expand Down Expand Up @@ -117,7 +118,7 @@ function html_footer($page, $sect, $sect_title, $flags, $footer_lvl, &$renderer)
// tags - let Tag Plugin do the work for us
if (empty($sect) && $flags['tags'] && (!plugin_isdisabled('tag')) && ($tag = plugin_load('helper', 'tag'))) {
$tags = $tag->td($page);
if($tags) {
if ($tags) {
$xhtml .= '<div class="tags"><span>' . DOKU_LF
. DOKU_TAB . $tags . DOKU_LF
. DOKU_TAB . '</span></div>' . DOKU_LF;
Expand Down
48 changes: 28 additions & 20 deletions syntax/header.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

use dokuwiki\Extension\SyntaxPlugin;

/**
* Include plugin (permalink header component)
*
Expand All @@ -9,58 +12,62 @@
* @author Michael Klier <chi@chimeric.de>
*/

class syntax_plugin_include_header extends DokuWiki_Syntax_Plugin {

function getType() {
class syntax_plugin_include_header extends SyntaxPlugin
{
public function getType()
{
return 'formatting';
}

function getSort() {

public function getSort()
{
return 50;
}

function handle($match, $state, $pos, Doku_Handler $handler) {
public function handle($match, $state, $pos, Doku_Handler $handler)
{
// this is a syntax plugin that doesn't offer any syntax, so there's nothing to handle by the parser
}

/**
* Renders a permalink header.
*
*
* Code heavily copied from the header renderer from inc/parser/xhtml.php, just
* added an href parameter to the anchor tag linking to the wikilink.
*/
function render($mode, Doku_Renderer $renderer, $data) {
public function render($mode, Doku_Renderer $renderer, $data)
{
global $conf;

list($headline, $lvl, $pos, $page, $sect, $flags) = $data;
[$headline, $lvl, $pos, $page, $sect, $flags] = $data;

if ($mode == 'xhtml') {
/** @var Doku_Renderer_xhtml $renderer */
$hid = $renderer->_headerToLink($headline, true);
$renderer->toc_additem($hid, $headline, $lvl);
$url = ($sect) ? wl($page) . '#' . $sect : wl($page);
$renderer->doc .= DOKU_LF.'<h' . $lvl;
$classes = array();
if($flags['taglogos']) {
$renderer->doc .= DOKU_LF . '<h' . $lvl;
$classes = [];
if ($flags['taglogos']) {
$tag = $this->_get_firsttag($page);
if($tag) {
if ($tag) {
$classes[] = 'include_firsttag__' . $tag;
}
}
// the include header instruction is always at the beginning of the first section edit inside the include
// wrap so there is no need to close a previous section edit.
if ($lvl <= $conf['maxseclevel']) {
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
$classes[] = $renderer->startSectionEdit($pos, array('target' => 'section', 'name' => $headline, 'hid' => $hid));
$classes[] = $renderer->startSectionEdit($pos, ['target' => 'section', 'name' => $headline, 'hid' => $hid]);
} else {
$classes[] = $renderer->startSectionEdit($pos, 'section', $headline);
}
}
if ($classes) {
$renderer->doc .= ' class="'. implode(' ', $classes) . '"';
$renderer->doc .= ' class="' . implode(' ', $classes) . '"';
}
$headline = $renderer->_xmlEntities($headline);
$renderer->doc .= ' id="'.$hid.'"><a href="' . $url . '" title="' . $headline . '">';
$renderer->doc .= ' id="' . $hid . '"><a href="' . $url . '" title="' . $headline . '">';
$renderer->doc .= $headline;
$renderer->doc .= '</a></h' . $lvl . '>' . DOKU_LF;
return true;
Expand All @@ -75,17 +82,18 @@ function render($mode, Doku_Renderer $renderer, $data) {
*
* @author Michael Klier <chi@chimeric.de>
*/
function _get_firsttag($page) {
if(plugin_isdisabled('tag') || (!plugin_load('helper', 'tag'))) {
public function _get_firsttag($page)
{
if (plugin_isdisabled('tag') || (!plugin_load('helper', 'tag'))) {
return false;
}
$subject = p_get_metadata($page, 'subject');
if (is_array($subject)) {
$tag = $subject[0];
} else {
list($tag, $rest) = explode(' ', $subject, 2);
[$tag, $rest] = explode(' ', $subject, 2);
}
if($tag) {
if ($tag) {
return $tag;
} else {
return false;
Expand Down
Loading