Skip to content

Commit

Permalink
Automatic PSR-2 code style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
annda committed Jan 25, 2021
1 parent 2c2c39a commit 0c86db3
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 107 deletions.
29 changes: 16 additions & 13 deletions action.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
<?php

/**
* Changes Plugin: List the most recent changes of the wiki
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
* @author Mykola Ostrovskyy <spambox03@mail.ru>
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

/**
* Class action_plugin_changes
*/
class action_plugin_changes extends DokuWiki_Action_Plugin {

class action_plugin_changes extends DokuWiki_Action_Plugin
{
/**
* Register callbacks
* @param Doku_Event_Handler $controller
*/
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'beforeParserCacheUse');
public function register(Doku_Event_Handler $controller)
{
$controller->register_hook('PARSER_CACHE_USE', 'BEFORE', $this, 'beforeParserCacheUse');
}

/**
* Handle PARSER_CACHE_USE:BEFORE event
* @param Doku_Event $event
*/
public function beforeParserCacheUse($event, $param) {
public function beforeParserCacheUse($event)
{
global $ID;
$cache = $event->data;
if(isset($cache->mode) && ($cache->mode == 'xhtml')){
if (isset($cache->mode) && ($cache->mode == 'xhtml')) {
$depends = p_get_metadata($ID, 'relation depends');
if(!empty($depends) && isset($depends['rendering'])){
if (!empty($depends) && isset($depends['rendering'])) {
$this->addDependencies($cache, array_keys($depends['rendering']));
}
}
Expand All @@ -38,8 +41,8 @@ public function beforeParserCacheUse($event, $param) {
/**
* Add extra dependencies to the cache
*/
protected function addDependencies($cache, $depends) {

protected function addDependencies($cache, $depends)
{
// Prevent "Warning: in_array() expects parameter 2 to be array, null given"
if (!is_array($cache->depends)) {
$cache->depends = array();
Expand All @@ -48,8 +51,8 @@ protected function addDependencies($cache, $depends) {
$cache->depends['files'] = array();
}

foreach($depends as $file){
if(!in_array($file, $cache->depends['files']) && @file_exists($file)){
foreach ($depends as $file) {
if (!in_array($file, $cache->depends['files']) && @file_exists($file)) {
$cache->depends['files'][] = $file;
}
}
Expand Down
Loading

0 comments on commit 0c86db3

Please sign in to comment.