From 0a48ad6308986ef125adf850422320b1231bd3f8 Mon Sep 17 00:00:00 2001 From: Kai_WMDE Date: Tue, 10 Nov 2015 14:53:07 +0100 Subject: [PATCH] applied coding conventions --- inc/wikibox.class.php | 52 ++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/inc/wikibox.class.php b/inc/wikibox.class.php index dbd43b6..c3024c1 100644 --- a/inc/wikibox.class.php +++ b/inc/wikibox.class.php @@ -1,48 +1,58 @@ rip_page($listPage, 'raw', $purge); - if (!$list && !$testPage) return false; + $list = $this->rip_page( $listPage, 'raw', $purge ); + if ( !$list && !$testPage ) { + return false; + } - $list = preg_replace('@@s', '', $list); - if (!preg_match_all('/^\*+.*\[\[(.+?)( *\|.*?)?\]\]/m', $list, $mm, PREG_SET_ORDER)) $mm = array(); - if (!$mm && !$testPage) return false; + $list = preg_replace( '@@s', '', $list ); + if ( !preg_match_all( '/^\*+.*\[\[(.+?)( *\|.*?)?\]\]/m', $list, $mm, PREG_SET_ORDER ) ) { + $mm = array(); + } + if ( !$mm && !$testPage) { + return false; + } $list = array(); - foreach ($mm as $m) { - $list[] = WikiRip::normalizeTitle($m[1]); + foreach ( $mm as $m ) { + $list[] = WikiRip::normalizeTitle( $m[1] ); } if ( $testPage ) { - $page = WikiRip::normalizeTitle("Web:{$testPage}"); + $page = WikiRip::normalizeTitle( "Web:{$testPage}" ); $this->cache_duration = 0; //disable cache for testing - $html = $this->rip_page($page, 'render', true); - if (!$html) $html = "page not found: ".htmlspecialchars($page).""; - else if (!in_array($page, $list) && !preg_match('/wikibox-test/i', $html)) $html = "inactive feature page not marked with \"wikibox-test\": ".htmlspecialchars($page).""; + $html = $this->rip_page( $page, 'render', true ); + if ( !$html ) { + $html = 'page not found: ' . htmlspecialchars( $page ) . ''; + } else if ( !in_array( $page, $list ) && !preg_match( '/wikibox-test/i', $html ) ) { + $html = 'inactive feature page not marked with "wikibox-test": ' . htmlspecialchars( $page ) . ''; + } } else { - $i = mt_rand(0, count($list)-1 ); + $i = mt_rand( 0, count( $list ) - 1 ); $page = $list[$i]; - $html = $this->rip_page($page, 'render', $purge); - if (!$html) return false; + $html = $this->rip_page( $page, 'render', $purge ); + if ( !$html ) { + return false; + } } - if ($html) { - $html = preg_replace('!(<(span|div)[^<>]*>)?\s*BEGIN_NORIP.*?END_NORIP\s*()?!', '', $html); - $html = preg_replace('!(<(span|div)[^<>]*wikibox-test[^<>]*>).*()!', '', $html); + if ( $html ) { + $html = preg_replace( '!(<(span|div)[^<>]*>)?\s*BEGIN_NORIP.*?END_NORIP\s*()?!', '', $html ); + $html = preg_replace( '!(<(span|div)[^<>]*wikibox-test[^<>]*>).*()!', '', $html ); } return $html; } } -