const AS_HOOK_ERROR = 210;
/**
- * Status: The filter function set in $wgFilterCallback returned true (= block it)
+ * Status: The filter function set in $wgFilterCallback returned true (= block it)
*/
const AS_FILTERING = 211;
* @var ParserOutput
*/
var $mParserOutput;
-
+
/**
* Has a summary been preset using GET parameter &summary= ?
* @var Bool
}
wfProfileIn( __METHOD__ );
- wfDebug( __METHOD__.": enter\n" );
+ wfDebug( __METHOD__ . ": enter\n" );
// If they used redlink=1 and the page exists, redirect to the main article
if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) {
return;
}
- wfProfileIn( __METHOD__."-business-end" );
+ wfProfileIn( __METHOD__ . "-business-end" );
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
if ( 'save' == $this->formtype ) {
if ( !$this->attemptSave() ) {
- wfProfileOut( __METHOD__."-business-end" );
+ wfProfileOut( __METHOD__ . "-business-end" );
wfProfileOut( __METHOD__ );
return;
}
if ( 'initial' == $this->formtype || $this->firsttime ) {
if ( $this->initialiseForm() === false ) {
$this->noSuchSectionPage();
- wfProfileOut( __METHOD__."-business-end" );
+ wfProfileOut( __METHOD__ . "-business-end" );
wfProfileOut( __METHOD__ );
return;
}
}
$this->showEditForm();
- wfProfileOut( __METHOD__."-business-end" );
+ wfProfileOut( __METHOD__ . "-business-end" );
wfProfileOut( __METHOD__ );
}
}
# Ignore some permissions errors when a user is just previewing/viewing diffs
$remove = array();
- foreach( $permErrors as $error ) {
+ foreach ( $permErrors as $error ) {
if ( ( $this->preview || $this->diff ) &&
( $error[0] == 'blockedtext' || $error[0] == 'autoblockedtext' ) )
{
*/
function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
wfDeprecated( __METHOD__, '1.19' );
-
+
global $wgRequest, $wgOut;
if ( $wgRequest->getBool( 'redlink' ) ) {
// The edit page was reached via a red link.
// Standard preference behaviour
return true;
} elseif ( !$this->mTitle->exists() &&
- isset($wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()]) &&
+ isset( $wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] ) &&
$wgPreviewOnOpenNamespaces[$this->mTitle->getNamespace()] )
{
// Categories are special
* @return bool
*/
protected function isWrongCaseCssJsPage() {
- if( $this->mTitle->isCssJsSubpage() ) {
+ if ( $this->mTitle->isCssJsSubpage() ) {
$name = $this->mTitle->getSkinFromCssJsSubpage();
$skins = array_merge(
array_keys( Skin::getSkinNames() ),
# Also remove trailing whitespace, but don't remove _initial_
# whitespace from the text boxes. This may be significant formatting.
$this->textbox1 = $this->safeUnicodeInput( $request, 'wpTextbox1' );
- if ( !$request->getCheck('wpTextbox2') ) {
+ if ( !$request->getCheck( 'wpTextbox2' ) ) {
// Skip this if wpTextbox2 has input, it indicates that we came
// from a conflict page with raw page text, not a custom form
// modified by subclasses
- wfProfileIn( get_class($this)."::importContentFormData" );
+ wfProfileIn( get_class( $this ) . "::importContentFormData" );
$textbox1 = $this->importContentFormData( $request );
- if ( isset($textbox1) )
+ if ( isset( $textbox1 ) )
$this->textbox1 = $textbox1;
- wfProfileOut( get_class($this)."::importContentFormData" );
+ wfProfileOut( get_class( $this ) . "::importContentFormData" );
}
# Truncate for whole multibyte characters. +5 bytes for ellipsis
# header syntax, e.g. 'Foobar'. This is mainly an issue when we are using wpSummary for
# section titles.
$this->summary = preg_replace( '/^\s*=+\s*(.*?)\s*=+\s*$/', '$1', $this->summary );
-
+
# Treat sectiontitle the same way as summary.
# Note that wpSectionTitle is not yet a part of the actual edit form, as wpSummary is
# currently doing double duty as both edit summary and section title. Right now this
{
$this->allowBlankSummary = true;
} else {
- $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary');
+ $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary' );
}
$this->autoSumm = $request->getText( 'wpAutoSummary' );
$this->minoredit = false;
$this->watchthis = $request->getBool( 'watchthis', false ); // Watch may be overriden by request parameters
$this->recreate = false;
-
+
// When creating a new section, we can preload a section title by passing it as the
// preloadtitle parameter in the URL (Bug 13100)
if ( $this->section == 'new' && $request->getVal( 'preloadtitle' ) ) {
if ( !empty( $this->mPreloadText ) ) {
return $this->mPreloadText;
}
-
+
if ( $preload === '' ) {
return '';
}
if ( $this->sectiontitle !== '' ) {
// Insert the section title above the content.
$text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->sectiontitle ) . "\n\n" . $text;
-
+
// Jump to the new section
$result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
-
+
// If no edit summary was specified, create one automatically from the section
// title and have it link to the new section. Otherwise, respect the summary as
// passed.
} elseif ( $this->summary !== '' ) {
// Insert the section title above the content.
$text = wfMsgForContent( 'newsectionheaderdefaultlevel', $this->summary ) . "\n\n" . $text;
-
+
// Jump to the new section
$result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
} else {
// New comment; suppress conflict.
$this->isConflict = false;
- wfDebug( __METHOD__ .": conflict suppressed; new section\n" );
+ wfDebug( __METHOD__ . ": conflict suppressed; new section\n" );
}
} elseif ( $this->section == '' && $this->userWasLastToEdit( $wgUser->getId(), $this->edittime ) ) {
# Suppress edit conflict with self, except for section edits where merging is required.
$this->isConflict = false;
}
}
-
+
// If sectiontitle is set, use it, otherwise use the summary as the section title (for
// backwards compatibility with old forms/bots).
if ( $this->sectiontitle !== '' ) {
} else {
$sectionTitle = $this->summary;
}
-
+
if ( $this->isConflict ) {
wfDebug( __METHOD__ . ": conflict! getting section '$this->section' for time '$this->edittime' (article time '{$timestamp}')\n" );
$text = $this->mArticle->replaceSection( $this->section, $this->textbox1, $sectionTitle, $this->edittime );
* @return bool
*/
protected function userWasLastToEdit( $id, $edittime ) {
- if( !$id ) return false;
+ if ( !$id ) return false;
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->select( 'revision',
'rev_user',
array(
'rev_page' => $this->mTitle->getArticleId(),
- 'rev_timestamp > '.$dbw->addQuotes( $dbw->timestamp($edittime) )
+ 'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $edittime ) )
),
__METHOD__,
array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ) );
foreach ( $res as $row ) {
- if( $row->rev_user != $id ) {
+ if ( $row->rev_user != $id ) {
return false;
}
}
*
* @return bool
*/
- function mergeChangesInto( &$editText ){
+ function mergeChangesInto( &$editText ) {
wfProfileIn( __METHOD__ );
$db = wfGetDB( DB_MASTER );
* @return bool|string
*/
protected static function matchSpamRegexInternal( $text, $regexes ) {
- foreach( $regexes as $regex ) {
+ foreach ( $regexes as $regex ) {
$matches = array();
- if( preg_match( $regex, $text, $matches ) ) {
+ if ( preg_match( $regex, $text, $matches ) ) {
return $matches[0];
}
}
$username = $parts[0];
$user = User::newFromName( $username, false /* allow IP users*/ );
$ip = User::isIP( $username );
- if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist
+ if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
$wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
array( 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ) );
} elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
'', array( 'lim' => 10,
'conds' => array( "log_action != 'revision'" ),
'showIfEmpty' => false,
- 'msgKey' => array( 'recreate-moveddeleted-warn') )
+ 'msgKey' => array( 'recreate-moveddeleted-warn' ) )
);
}
}
wfProfileIn( __METHOD__ );
- #need to parse the preview early so that we know which templates are used,
- #otherwise users with "show preview after edit box" will get a blank list
- #we parse this near the beginning so that setHeaders can do the title
- #setting work instead of leaving it in getPreviewText
+ # need to parse the preview early so that we know which templates are used,
+ # otherwise users with "show preview after edit box" will get a blank list
+ # we parse this near the beginning so that setHeaders can do the title
+ # setting work instead of leaving it in getPreviewText
$previewOutput = '';
if ( $this->formtype == 'preview' ) {
$previewOutput = $this->getPreviewText();
// If a summary has been preset using &summary= we dont want to prompt for
// a different summary. Only prompt for a summary if the summary is blanked.
// (Bug 17416)
- $this->autoSumm = md5('');
+ $this->autoSumm = md5( '' );
}
-
+
$autosumm = $this->autoSumm ? $this->autoSumm : md5( $this->summary );
$wgOut->addHTML( Html::hidden( 'wpAutoSummary', $autosumm ) );
preg_match( "/^(=+)(.+)\\1(\n|$)/i", $text, $matches );
if ( !empty( $matches[2] ) ) {
global $wgParser;
- return $wgParser->stripSectionName(trim($matches[2]));
+ return $wgParser->stripSectionName( trim( $matches[2] ) );
} else {
return false;
}
}
# Optional notices on a per-namespace and per-page basis
- $editnotice_ns = 'editnotice-'.$this->mTitle->getNamespace();
+ $editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
$editnotice_ns_message = wfMessage( $editnotice_ns )->inContentLanguage();
if ( $editnotice_ns_message->exists() ) {
$wgOut->addWikiText( $editnotice_ns_message->plain() );
$parts = explode( '/', $this->mTitle->getDBkey() );
$editnotice_base = $editnotice_ns;
while ( count( $parts ) > 0 ) {
- $editnotice_base .= '-'.array_shift( $parts );
+ $editnotice_base .= '-' . array_shift( $parts );
$editnotice_base_msg = wfMessage( $editnotice_base )->inContentLanguage();
if ( $editnotice_base_msg->exists() ) {
- $wgOut->addWikiText( $editnotice_base_msg->plain() );
+ $wgOut->addWikiText( $editnotice_base_msg->plain() );
}
}
} else {
}
if ( $this->mTitle->isCascadeProtected() ) {
# Is this page under cascading protection from some source pages?
- list($cascadeSources, /* $restrictions */) = $this->mTitle->getCascadeProtectionSources();
+ list( $cascadeSources, /* $restrictions */ ) = $this->mTitle->getCascadeProtectionSources();
$notice = "<div class='mw-cascadeprotectedwarning'>\n$1\n";
$cascadeSourcesCount = count( $cascadeSources );
if ( $cascadeSourcesCount > 0 ) {
# Explain, and list the titles responsible
- foreach( $cascadeSources as $page ) {
+ foreach ( $cascadeSources as $page ) {
$notice .= '* [[:' . $page->getPrefixedText() . "]]\n";
}
}
}
if ( !$this->mTitle->exists() && $this->mTitle->getRestrictions( 'create' ) ) {
LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '',
- array( 'lim' => 1,
+ array( 'lim' => 1,
'showIfEmpty' => false,
'msgKey' => array( 'titleprotectedwarning' ),
'wrap' => "<div class=\"mw-titleprotectedwarning\">\n$1</div>" ) );
$wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
array( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ) );
} else {
- if( !wfMessage('longpage-hint')->isDisabled() ) {
+ if ( !wfMessage( 'longpage-hint' )->isDisabled() ) {
$wgOut->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
array( 'longpage-hint', $wgLang->formatSize( strlen( $this->textbox1 ) ), strlen( $this->textbox1 ) )
);
*
* @return array An array in the format array( $label, $input )
*/
- function getSummaryInput($summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null) {
- //Note: the maxlength is overriden in JS to 250 and to make it use UTF-8 bytes, not characters.
- $inputAttrs = ( is_array($inputAttrs) ? $inputAttrs : array() ) + array(
+ function getSummaryInput( $summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null ) {
+ // Note: the maxlength is overriden in JS to 250 and to make it use UTF-8 bytes, not characters.
+ $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : array() ) + array(
'id' => 'wpSummary',
'maxlength' => '200',
'tabindex' => '1',
'spellcheck' => 'true',
) + Linker::tooltipAndAccesskeyAttribs( 'summary' );
- $spanLabelAttrs = ( is_array($spanLabelAttrs) ? $spanLabelAttrs : array() ) + array(
+ $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : array() ) + array(
'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
'id' => "wpSummaryLabel"
);
}
$summary = $wgContLang->recodeForEdit( $summary );
$labelText = wfMsgExt( $isSubjectPreview ? 'subject' : 'summary', 'parseinline' );
- list($label, $input) = $this->getSummaryInput($summary, $labelText, array( 'class' => $summaryClass ), array());
- $wgOut->addHTML("{$label} {$input}");
+ list( $label, $input ) = $this->getSummaryInput( $summary, $labelText, array( 'class' => $summaryClass ), array() );
+ $wgOut->addHTML( "{$label} {$input}" );
}
/**
HTML
);
if ( !$this->checkUnicodeCompliantBrowser() )
- $wgOut->addHTML(Html::hidden( 'safemode', '1' ));
+ $wgOut->addHTML( Html::hidden( 'safemode', '1' ) );
}
protected function showFormAfterText() {
global $wgOut, $wgUser;
$wikitext = $this->safeUnicodeOutput( $content );
- if ( strval($wikitext) !== '' ) {
+ if ( strval( $wikitext ) !== '' ) {
// Ensure there's a newline at the end, otherwise adding lines
// is awkward.
// But don't add a newline if the ext is empty, or Firefox in XHTML
$wgOut->addHTML( '</div>' );
- if ( $this->formtype == 'diff') {
+ if ( $this->formtype == 'diff' ) {
$this->showDiff();
}
}
*/
protected function showPreview( $text ) {
global $wgOut;
- if ( $this->mTitle->getNamespace() == NS_CATEGORY) {
+ if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
$this->mArticle->openShowCategory();
}
# This hook seems slightly odd here, but makes things more
# consistent for extensions.
- wfRunHooks( 'OutputPageBeforeHTML',array( &$wgOut, &$text ) );
+ wfRunHooks( 'OutputPageBeforeHTML', array( &$wgOut, &$text ) );
$wgOut->addHTML( $text );
if ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
$this->mArticle->closeShowCategory();
protected function showTosSummary() {
$msg = 'editpage-tos-summary';
wfRunHooks( 'EditPageTosSummary', array( $this->mTitle, &$msg ) );
- if( !wfMessage( $msg )->isDisabled() ) {
+ if ( !wfMessage( $msg )->isDisabled() ) {
global $wgOut;
$wgOut->addHTML( '<div class="mw-tos-summary">' );
$wgOut->addWikiMsg( $msg );
wfRunHooks( 'EditPageCopyrightWarning', array( $this->mTitle, &$copywarnMsg ) );
return "<div id=\"editpage-copywarn\">\n" .
- call_user_func_array("wfMsgNoTrans", $copywarnMsg) . "\n</div>";
+ call_user_func_array( "wfMsgNoTrans", $copywarnMsg ) . "\n</div>";
}
protected function showStandardInputs( &$tabindex = 2 ) {
$cancel .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
}
$edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) );
- $edithelp = '<a target="helpwindow" href="'.$edithelpurl.'">'.
- htmlspecialchars( wfMsg( 'edithelp' ) ).'</a> '.
+ $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
+ htmlspecialchars( wfMsg( 'edithelp' ) ) . '</a> ' .
htmlspecialchars( wfMsg( 'newwindow' ) );
$wgOut->addHTML( " <span class='editHelp'>{$cancel}{$edithelp}</span>\n" );
$wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" );
array( 'LIMIT' => 1, 'ORDER BY' => 'log_timestamp DESC' )
);
// Quick paranoid permission checks...
- if( is_object( $data ) ) {
- if( $data->log_deleted & LogPage::DELETED_USER )
+ if ( is_object( $data ) ) {
+ if ( $data->log_deleted & LogPage::DELETED_USER )
$data->user_name = wfMsgHtml( 'rev-deleted-user' );
- if( $data->log_deleted & LogPage::DELETED_COMMENT )
+ if ( $data->log_deleted & LogPage::DELETED_COMMENT )
$data->log_comment = wfMsgHtml( 'rev-deleted-comment' );
}
return $data;
$parserOptions->setEditSection( false );
$parserOptions->setTidy( true );
$parserOptions->setIsPreview( true );
- $parserOptions->setIsSectionPreview( !is_null($this->section) && $this->section !== '' );
+ $parserOptions->setIsSectionPreview( !is_null( $this->section ) && $this->section !== '' );
# don't parse non-wikitext pages, show message about preview
# XXX: stupid php bug won't let us use $this->getContextTitle()->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
if ( $this->isCssJsSubpage || !$this->mTitle->isWikitextPage() ) {
- if( $this->mTitle->isCssJsSubpage() ) {
+ if ( $this->mTitle->isCssJsSubpage() ) {
$level = 'user';
- } elseif( $this->mTitle->isCssOrJsPage() ) {
+ } elseif ( $this->mTitle->isCssOrJsPage() ) {
$level = 'site';
} else {
$level = false;
# Used messages to make sure grep find them:
# Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
- if( $level ) {
- if (preg_match( "/\\.css$/", $this->mTitle->getText() ) ) {
+ if ( $level ) {
+ if ( preg_match( "/\\.css$/", $this->mTitle->getText() ) ) {
$previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg( "{$level}csspreview" ) . "\n</div>";
$class = "mw-code mw-css";
- } elseif (preg_match( "/\\.js$/", $this->mTitle->getText() ) ) {
+ } elseif ( preg_match( "/\\.js$/", $this->mTitle->getText() ) ) {
$previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg( "{$level}jspreview" ) . "\n</div>";
$class = "mw-code mw-js";
} else {
}
}
- if( $this->isConflict ) {
+ if ( $this->isConflict ) {
$conflict = '<h2 id="mw-previewconflict">' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n";
} else {
$conflict = '<hr />';
$pageLang = $this->mTitle->getPageLanguage();
$attribs = array( 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(),
- 'class' => 'mw-content-'.$pageLang->getDir() );
+ 'class' => 'mw-content-' . $pageLang->getDir() );
$previewHTML = Html::rawElement( 'div', $attribs, $previewHTML );
wfProfileOut( __METHOD__ );
if ( !isset( $this->mParserOutput ) ) {
return $templates;
}
- foreach( $this->mParserOutput->getTemplates() as $ns => $template) {
- foreach( array_keys( $template ) as $dbk ) {
- $templates[] = Title::makeTitle($ns, $dbk);
+ foreach ( $this->mParserOutput->getTemplates() as $ns => $template ) {
+ foreach ( array_keys( $template ) as $dbk ) {
+ $templates[] = Title::makeTitle( $ns, $dbk );
}
}
return $templates;
'tip' => wfMsg( 'media_tip' ),
'key' => 'M'
) : false,
- $wgUseTeX ? array(
+ $wgUseTeX ? array(
'image' => $wgLang->getImageFile( 'button-math' ),
'id' => 'mw-editbutton-math',
'open' => "<math>",
$script .= Xml::encodeJsCall( 'mw.toolbar.addButton', $params );
}
-
+
// This used to be called on DOMReady from mediawiki.action.edit, which
// ended up causing race conditions with the setup code above.
$script .= "\n" .
'tabindex' => ++$tabindex,
'value' => wfMsg( 'savearticle' ),
'accesskey' => wfMsg( 'accesskey-save' ),
- 'title' => wfMsg( 'tooltip-save' ).' ['.wfMsg( 'accesskey-save' ).']',
+ 'title' => wfMsg( 'tooltip-save' ) . ' [' . wfMsg( 'accesskey-save' ) . ']',
);
- $buttons['save'] = Xml::element('input', $temp, '');
+ $buttons['save'] = Xml::element( 'input', $temp, '' );
++$tabindex; // use the same for preview and live preview
$temp = array(
*/
static function spamPage( $match = false ) {
wfDeprecated( __METHOD__, '1.17' );
-
+
global $wgOut, $wgTitle;
$wgOut->prepareErrorPage( wfMessage( 'spamprotectiontitle' ) );
}
$currentbrowser = $_SERVER["HTTP_USER_AGENT"];
foreach ( $wgBrowserBlackList as $browser ) {
- if ( preg_match($browser, $currentbrowser) ) {
+ if ( preg_match( $browser, $currentbrowser ) ) {
return false;
}
}
$bytesleft = 0;
$result = "";
$working = 0;
- for( $i = 0; $i < strlen( $invalue ); $i++ ) {
+ for ( $i = 0; $i < strlen( $invalue ); $i++ ) {
$bytevalue = ord( $invalue[$i] );
- if ( $bytevalue <= 0x7F ) { //0xxx xxxx
+ if ( $bytevalue <= 0x7F ) { // 0xxx xxxx
$result .= chr( $bytevalue );
$bytesleft = 0;
- } elseif ( $bytevalue <= 0xBF ) { //10xx xxxx
+ } elseif ( $bytevalue <= 0xBF ) { // 10xx xxxx
$working = $working << 6;
- $working += ($bytevalue & 0x3F);
+ $working += ( $bytevalue & 0x3F );
$bytesleft--;
if ( $bytesleft <= 0 ) {
$result .= "&#x" . strtoupper( dechex( $working ) ) . ";";
}
- } elseif ( $bytevalue <= 0xDF ) { //110x xxxx
+ } elseif ( $bytevalue <= 0xDF ) { // 110x xxxx
$working = $bytevalue & 0x1F;
$bytesleft = 1;
- } elseif ( $bytevalue <= 0xEF ) { //1110 xxxx
+ } elseif ( $bytevalue <= 0xEF ) { // 1110 xxxx
$working = $bytevalue & 0x0F;
$bytesleft = 2;
- } else { //1111 0xxx
+ } else { // 1111 0xxx
$working = $bytevalue & 0x07;
$bytesleft = 3;
}
*/
function unmakesafe( $invalue ) {
$result = "";
- for( $i = 0; $i < strlen( $invalue ); $i++ ) {
- if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue[$i+3] != '0' ) ) {
+ for ( $i = 0; $i < strlen( $invalue ); $i++ ) {
+ if ( ( substr( $invalue, $i, 3 ) == "&#x" ) && ( $invalue[$i + 3] != '0' ) ) {
$i += 3;
$hexstring = "";
do {
$hexstring .= $invalue[$i];
$i++;
- } while( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) );
+ } while ( ctype_xdigit( $invalue[$i] ) && ( $i < strlen( $invalue ) ) );
// Do some sanity checks. These aren't needed for reversability,
// but should help keep the breakage down if the editor
// breaks one of the entities whilst editing.
- if ( (substr($invalue,$i,1)==";") and (strlen($hexstring) <= 6) ) {
- $codepoint = hexdec($hexstring);
+ if ( ( substr( $invalue, $i, 1 ) == ";" ) and ( strlen( $hexstring ) <= 6 ) ) {
+ $codepoint = hexdec( $hexstring );
$result .= codepointToUtf8( $codepoint );
} else {
$result .= "&#x" . $hexstring . substr( $invalue, $i, 1 );