Ejemplo n.º 1
0
 /**
  * Displays the main upload form, optionally with a highlighted
  * error message up at the top.
  *
  * @param string $msg as HTML
  * @access private
  */
 function mainUploadForm($msg = '')
 {
     global $wgOut, $wgUser;
     global $wgUseCopyrightUpload;
     $cols = intval($wgUser->getOption('cols'));
     $ew = $wgUser->getOption('editwidth');
     if ($ew) {
         $ew = " style=\"width:100%\"";
     } else {
         $ew = '';
     }
     if ('' != $msg) {
         $sub = wfMsgHtml('uploaderror');
         $wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n");
     }
     $wgOut->addHTML('<div id="uploadtext">');
     $wgOut->addWikiText(wfMsg('uploadtext'));
     $wgOut->addHTML('</div>');
     $sk = $wgUser->getSkin();
     $sourcefilename = wfMsgHtml('sourcefilename');
     $destfilename = wfMsgHtml('destfilename');
     $summary = wfMsgWikiHtml('fileuploadsummary');
     $licenses = new Licenses();
     $license = wfMsgHtml('license');
     $nolicense = wfMsgHtml('nolicense');
     $licenseshtml = $licenses->getHtml();
     // WERELATE - added licenseHelp
     $licenseHelpUrl = $sk->makeInternalOrExternalUrl(wfMsgForContent('licensehelppage'));
     $licenseHelp = '<a target="helpwindow" href="' . $licenseHelpUrl . '">' . htmlspecialchars(wfMsg('licensehelp')) . '</a>';
     // WERELATE - added code to select proper license
     if ($this->mLicense) {
         $protectedLicense = str_replace(array('\\', '$', '^', '.', '[', ']', '|', '(', ')', '?', '*', '+', '{', '}', '-'), array('\\\\', '\\$', '\\^', '\\.', '\\[', '\\]', '\\|', '\\(', '\\)', '\\?', '\\*', '\\+', '\\{', '\\}', '\\-'), $this->mLicense);
         $licenseshtml = preg_replace('$value="(' . $protectedLicense . ')"$', 'value="$1" selected="selected"', $licenseshtml);
     }
     $ulb = wfMsgHtml('uploadbtn');
     $titleObj = Title::makeTitle(NS_SPECIAL, 'Upload');
     // WERELATE: added target and id
     $query = '';
     if ($this->mTarget) {
         $query = 'target=' . urlencode($this->mTarget) . '&id=' . urlencode($this->mId);
     }
     $action = $titleObj->escapeLocalURL($query);
     $encDestFile = htmlspecialchars($this->mDestFile);
     //WERELATE - added watchcreations
     $watchChecked = $wgUser->getOption('watchdefault') || $wgUser->getOption('watchcreations') ? 'checked="checked"' : '';
     // WERELATE - add scripts
     global $wgScriptPath;
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/image.1.js\"></script>");
     // WERELATE: removed tabindexes; added id to table
     $wgOut->addHTML("\n\t<form id='upload' method='post' enctype='multipart/form-data' action=\"{$action}\">\n\t\t<table id='image_form_table' border='0'>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile ? "" : "onchange='fillDestFilename()' ") . "size='40' />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpDestFile'>{$destfilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wpDestFile' id='wpDestFile' size='40' value=\"{$encDestFile}\" />\n\t\t\t</td>\n\t\t</tr>");
     // WERELATE - added check to omit fields in case of a re-upload, since they're ignored
     $treecheckboxeshtml = '';
     if (!$this->mReUploading) {
         $wgOut->addHTML("\n\t\t<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n\t\t<tr><td>&nbsp;</td><td align='left'><b>License and copyright</b></td></tr>\n\t\t<tr>");
         if ($licenseshtml != '') {
             global $wgStylePath;
             $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wpLicense'>{$license} (&nbsp;{$licenseHelp}&nbsp;):</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<script type='text/javascript' src=\"{$wgStylePath}/common/upload.2.js\"></script>\n\t\t\t\t<select name='wpLicense' id='wpLicense' \n\t\t\t\t\tonchange='licenseSelectorCheck()'>\n\t\t\t\t\t<option value=''>{$nolicense}</option>\n\t\t\t\t\t{$licenseshtml}\n\t\t\t\t</select>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t");
         }
         if ($wgUseCopyrightUpload) {
             $filestatus = wfMsgHtml('filestatus');
             $copystatus = htmlspecialchars($this->mUploadCopyStatus);
             $filesource = wfMsgHtml('filesource');
             $uploadsource = htmlspecialchars($this->mUploadSource);
             $wgOut->addHTML("\n\t\t\t        <td align='right' nowrap='nowrap'><label for='wpUploadCopyStatus'>{$filestatus}:</label></td>\n\t\t\t        <td><input type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus' value=\"{$copystatus}\" size='40' /></td>\n\t\t        </tr>\n\t\t\t<tr>\n\t\t        \t<td align='right'><label for='wpUploadCopyStatus'>{$filesource}:</label></td>\n\t\t\t        <td><input type='text' name='wpUploadSource' id='wpUploadCopyStatus' value=\"{$uploadsource}\" size='40' /></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t");
         }
         // WERELATE: added fields
         $personTbl = $this->toForm($this->mPeople, 'person', NS_PERSON, true);
         $familyTbl = $this->toForm($this->mFamilies, 'family', NS_FAMILY, true);
         $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wrCopyright'>Copyright holder:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrCopyright' id='wrCopyright' size='30' value=\"" . htmlspecialchars($this->mCopyright) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n\t\t<tr><td>&nbsp;</td><td align='left'><b>Time place and people</b></td></tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrDate'>Image date:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrDate' id='wrDate' size='15' value=\"" . htmlspecialchars($this->mDate) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrPlace'>Place:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input class='place_input' type='text' name='wrPlace' id='wrDate' size='30' value=\"" . htmlspecialchars($this->mPlace) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Person page:</td>\n\t\t\t<td align='left'>{$personTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td align='left'><a id='person_link' href='javascript:void(0)' onClick='addImagePage(\"person\"); return preventDefaultAction(event);'>Add another person</a></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Family page:</td>\n\t\t\t<td align='left'>{$familyTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td>&nbsp;</td>\n\t\t\t<td align='left'><a id='family_link' href='javascript:void(0)' onClick='addImagePage(\"family\"); return preventDefaultAction(event);'>Add another family</a></td>\n\t\t</tr>\n\t\t");
         // WERELATE - move description from above; end reUploading if statement; moved summary label
         //            add id for wpUpload; added tree checkboxes
         //!!! remove this code dependency before sharing
         require_once "extensions/familytree/FamilyTreeUtil.php";
         $t = null;
         if ($this->mDestFile) {
             $t = Title::newFromText($this->mDestFile, NS_IMAGE);
         }
         $treecheckboxeshtml = FamilyTreeUtil::generateTreeCheckboxes($wgUser, $t, true);
         $wgOut->addHtml("\n\t\t\t<tr><td>&nbsp;</td><td>&nbsp;</td></tr>\n\t\t\t<tr><td></td><td align='left'><b>{$summary}</b></td></tr>\n\t\t\t<tr><td></td><td align='left'>\n\t\t\t\t<textarea name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars($this->mUploadDescription) . "</textarea>\n\t\t\t</td>\n\t\t</tr> ");
     }
     $wgOut->addHTML("\n\t\t<tr>\n\t\t<td></td>\n\t\t<td>\n\t\t\t<input type='checkbox' name='wpWatchthis' id='wpWatchthis' {$watchChecked} value='true' />\n\t\t\t<label for='wpWatchthis'>" . wfMsgHtml('watchthis') . "</label>\n\t\t\t<input type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' />\n\t\t\t<label for='wpIgnoreWarning'>" . wfMsgHtml('ignorewarnings') . "</label>" . $treecheckboxeshtml . "\n\t\t</td>\n\t</tr>\n\t<tr>\n\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'><input type='submit' id='wpUpload' name='wpUpload' value=\"{$ulb}\" /></td>\n\t</tr>\n\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'>\n\t\t");
     $wgOut->addWikiText(wfMsgForContent('edittools'));
     $wgOut->addHTML("\n\t\t</td>\n\t</tr>\n\n\t</table>\n\t</form>");
 }
Ejemplo n.º 2
0
    /**
     * Send the edit form and related headers to $wgOut
     * @param $formCallback Optional callable that takes an OutputPage
     *                      parameter; will be called during form output
     *                      near the top, for captchas and the like.
     */
    function showEditForm($formCallback = null)
    {
        global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize;
        $fname = 'EditPage::showEditForm';
        wfProfileIn($fname);
        $sk =& $wgUser->getSkin();
        wfRunHooks('EditPage::showEditForm:initial', array(&$this));
        $wgOut->setRobotpolicy('noindex,nofollow');
        # Enabled article-related sidebar, toplinks, etc.
        $wgOut->setArticleRelated(true);
        if ($this->isConflict) {
            $s = wfMsg('editconflict', $this->mTitle->getPrefixedText());
            $wgOut->setPageTitle($s);
            $wgOut->addWikiText(wfMsg('explainconflict'));
            $this->textbox2 = $this->textbox1;
            $this->textbox1 = $this->getContent();
            $this->edittime = $this->mArticle->getTimestamp();
        } else {
            if ($this->section != '') {
                if ($this->section == 'new') {
                    $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText());
                } else {
                    // WERELATE: distinguish section from topic
                    $s = wfMsg($this->mTitle->isTalkPage() ? 'editingtopic' : 'editingsection', $this->mTitle->getPrefixedText());
                    if (!$this->preview && !$this->diff) {
                        preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches);
                        if (!empty($matches[2])) {
                            // WERELATE: remove date from summary for topics
                            if ($this->mTitle->isTalkPage()) {
                                $matches[2] = preg_replace('/\\[[^\\]]+\\] *$/', '', $matches[2]);
                            }
                            $this->summary = "/* " . trim($matches[2]) . " */ ";
                        }
                    }
                }
            } else {
                $s = wfMsg('editing', $this->mTitle->getPrefixedText());
            }
            $wgOut->setPageTitle($s);
            if ($this->missingComment) {
                $wgOut->addWikiText(wfMsg('missingcommenttext'));
            }
            if ($this->missingSummary) {
                $wgOut->addWikiText(wfMsg('missingsummary'));
            }
            if (!$this->hookError == '') {
                $wgOut->addWikiText($this->hookError);
            }
            if (!$this->checkUnicodeCompliantBrowser()) {
                $wgOut->addWikiText(wfMsg('nonunicodebrowser'));
            }
            if (isset($this->mArticle) && isset($this->mArticle->mRevision) && !$this->mArticle->mRevision->isCurrent()) {
                $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId());
                $wgOut->addWikiText(wfMsg('editingold'));
            }
        }
        if (wfReadOnly()) {
            $wgOut->addWikiText(wfMsg('readonlywarning'));
        } elseif ($wgUser->isAnon() && $this->formtype != 'preview') {
            $wgOut->addWikiText(wfMsg('anoneditwarning'));
        } else {
            if ($this->isCssJsSubpage && $this->formtype != 'preview') {
                # Check the skin exists
                if ($this->isValidCssJsSubpage) {
                    $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview'));
                } else {
                    $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
                }
            }
        }
        if ($this->mTitle->isProtected('edit')) {
            # Is the protection due to the namespace, e.g. interface text?
            if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) {
                # Yes; remind the user
                $notice = wfMsg('editinginterface');
            } elseif ($this->mTitle->isSemiProtected()) {
                # No; semi protected
                $notice = wfMsg('semiprotectedpagewarning');
                if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') {
                    $notice = '';
                }
            } else {
                # No; regular protection
                $notice = wfMsg('protectedpagewarning');
            }
            $wgOut->addWikiText($notice);
        }
        if ($this->kblength === false) {
            $this->kblength = (int) (strlen($this->textbox1) / 1024);
        }
        if ($this->tooBig || $this->kblength > $wgMaxArticleSize) {
            $wgOut->addWikiText(wfMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize));
        }
        $rows = $wgUser->getIntOption('rows');
        $cols = $wgUser->getIntOption('cols');
        $ew = $wgUser->getOption('editwidth');
        if ($ew) {
            $ew = " style=\"width:100%\"";
        } else {
            $ew = '';
        }
        $q = 'action=submit';
        #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
        $action = $this->mTitle->escapeLocalURL($q);
        $summary = wfMsg('summary');
        $subject = wfMsg('subject');
        $minor = wfMsgExt('minoredit', array('parseinline'));
        $watchthis = wfMsgExt('watchthis', array('parseinline'));
        $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline')));
        $edithelpurl = $sk->makeInternalOrExternalUrl(wfMsgForContent('edithelppage'));
        $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow'));
        global $wgRightsText;
        $copywarn = "<div id=\"editpage-copywarn\">\n" . wfMsg($wgRightsText ? 'copyrightwarning' : 'copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText) . "\n</div>";
        if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) {
            # prepare toolbar for edit buttons
            $toolbar = $this->getEditToolbar();
        } else {
            $toolbar = '';
        }
        // activate checkboxes if user wants them to be always active
        if (!$this->preview && !$this->diff) {
            # Sort out the "watch" checkbox
            if ($wgUser->getOption('watchdefault')) {
                # Watch all edits
                $this->watchthis = true;
            } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) {
                # Watch creations
                $this->watchthis = true;
            } elseif ($this->mTitle->userIsWatching()) {
                # Already watched
                $this->watchthis = true;
            }
            if ($wgUser->getOption('minordefault')) {
                $this->minoredit = true;
            }
        }
        $minoredithtml = '';
        if ($wgUser->isAllowed('minoredit')) {
            $minoredithtml = "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n";
        }
        $watchhtml = '';
        if ($wgUser->isLoggedIn()) {
            $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis'  />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n";
        }
        $checkboxhtml = $minoredithtml . $watchhtml;
        if ($wgUser->getOption('previewontop')) {
            if ('preview' == $this->formtype) {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ('diff' == $this->formtype) {
                $wgOut->addHTML($this->getDiff());
            }
        }
        # if this is a comment, show a subject line at the top, which is also the edit summary.
        # Otherwise, show a summary field at the bottom
        $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary));
        # FIXME
        if ($this->section == 'new') {
            // WERELATE - added extra br
            $commentsubject = "<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br /><br />";
            $editsummary = '';
        } else {
            $commentsubject = '';
            $editsummary = "<span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />";
        }
        # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display
        if (!$this->preview && !$this->diff) {
            // WERELATE - removed -- nothing can be in the onload handler because it might mess up JQuery
            //			$wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' );
        }
        $templates = $this->formatTemplates();
        global $wgUseMetadataEdit;
        if ($wgUseMetadataEdit) {
            $metadata = $this->mMetaData;
            $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata));
            $top = wfMsgWikiHtml('metadata_help');
            $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>";
        } else {
            $metadata = "";
        }
        $hidden = '';
        $recreate = '';
        if ($this->deletedSinceEdit) {
            if ('save' != $this->formtype) {
                $wgOut->addWikiText(wfMsg('deletedwhileediting'));
            } else {
                // Hide the toolbar and edit area, use can click preview to get it back
                // Add an confirmation checkbox and explanation.
                $toolbar = '';
                $hidden = 'type="hidden" style="display:none;"';
                $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment));
                $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>";
            }
        }
        // WERELATE - add script to protect leaving edited page
        $wgOut->addScript(<<<END
<script type="text/javascript">
//<![CDATA[
var needConfirm=(window.location.href.indexOf('&action=submit') > 0);
\$(document).ready(function() { \$("#editform :input").change(function(){ needConfirm=true; })});
window.onbeforeunload = function() { if (needConfirm) return "If you leave, any edits will be lost."; };
//]]>
</script>
END
);
        $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => '5', 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save'), 'onClick' => 'needConfirm=false');
        $buttons['save'] = wfElement('input', $temp, '');
        $temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => '7', 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff'), 'onClick' => 'needConfirm=false');
        $buttons['diff'] = wfElement('input', $temp, '');
        global $wgLivePreview;
        if ($wgLivePreview && $wgUser->getOption('uselivepreview')) {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => '', 'title' => wfMsg('tooltip-preview'), 'style' => 'display: none;', 'onClick' => 'needConfirm=false');
            $buttons['preview'] = wfElement('input', $temp, '');
            $temp = array('id' => 'wpLivePreview', 'name' => 'wpLivePreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showlivepreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => '', 'onclick' => $this->doLivePreviewScript() . '; needConfirm=false');
            $buttons['live'] = wfElement('input', $temp, '');
        } else {
            $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview'), 'onClick' => 'needConfirm=false');
            $buttons['preview'] = wfElement('input', $temp, '');
            $buttons['live'] = '';
        }
        $safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n";
        // WERELATE - moved toolbar from here to below
        $wgOut->addHTML(<<<END
<form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data">
END
);
        if (is_callable($formCallback)) {
            call_user_func_array($formCallback, array(&$wgOut));
        }
        // Put these up at the top to ensure they aren't lost on early form submission
        // WERELATE - add cmt
        $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"" . htmlspecialchars($this->cmt) . "\" name=\"wpCmt\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n");
        // WERELATE - added wfRunHooks, moved {$toolbar} from above, added treecheckboxeshtml
        require_once "extensions/familytree/FamilyTreeUtil.php";
        $treecheckboxeshtml = FamilyTreeUtil::generateTreeCheckboxes($wgUser, $this->mTitle, true);
        wfRunHooks('ArticleEditShow', array(&$this));
        $wgOut->addHTML(<<<END
{$recreate}
{$commentsubject}
{$toolbar}
<textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}'
cols='{$cols}'{$ew} {$hidden}>
END
 . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t");
        $wgOut->addWikiText($copywarn);
        $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$checkboxhtml}\n{$treecheckboxeshtml}\n{$safemodehtml}\n");
        $wgOut->addHTML("<div class='editButtons'>\n\t{$buttons['save']}\n\t{$buttons['preview']}\n\t{$buttons['live']}\n\t{$buttons['diff']}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->");
        $wgOut->addWikiText(wfMsgForContent('edittools'));
        $wgOut->addHTML("\n<div class='templatesUsed'>\n{$templates}\n</div>\n");
        if ($wgUser->isLoggedIn()) {
            /**
             * To make it harder for someone to slip a user a page
             * which submits an edit form to the wiki without their
             * knowledge, a random token is associated with the login
             * session. If it's not passed back with the submission,
             * we won't save the page, or render user JavaScript and
             * CSS previews.
             */
            $token = htmlspecialchars($wgUser->editToken());
            $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n");
        }
        # If a blank edit summary was previously provided, and the appropriate
        # user preference is active, pass a hidden tag here. This will stop the
        # user being bounced back more than once in the event that a summary
        # is not required.
        if ($this->missingSummary) {
            $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n");
        }
        # For a bit more sophisticated detection of blank summaries, hash the
        # automatic one and pass that in a hidden field.
        $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary);
        $wgOut->addHtml(wfHidden('wpAutoSummary', $autosumm));
        if ($this->isConflict) {
            require_once "DifferenceEngine.php";
            $wgOut->addWikiText('==' . wfMsg("yourdiff") . '==');
            $de = new DifferenceEngine($this->mTitle);
            $de->setText($this->textbox2, $this->textbox1);
            $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion"));
            $wgOut->addWikiText('==' . wfMsg("yourtext") . '==');
            $wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>");
        }
        $wgOut->addHTML("</form>\n");
        if (!$wgUser->getOption('previewontop')) {
            if ($this->formtype == 'preview') {
                $this->showPreview();
            } else {
                $wgOut->addHTML('<div id="wikiPreview"></div>');
            }
            if ($this->formtype == 'diff') {
                $wgOut->addHTML($this->getDiff());
            }
        }
        wfProfileOut($fname);
    }
Ejemplo n.º 3
0
    private function formatResults($response, $recentDocs, $selfQuery)
    {
        global $wgUser;
        $output = '';
        $start = $response['response']['start'];
        $numFound = $response['response']['numFound'];
        $end = $start + $this->rows;
        if ($end > $numFound) {
            $end = $numFound;
        }
        if ($this->target && $this->namespace != 'Image') {
            // can't currently add images from here; just select them
            $jsFunction = $this->getAddJSFunction() . '; return preventDefaultAction(event);';
            $output .= "<table><tr><td><input type=\"submit\" value=\"Add Page\" onClick=\"{$jsFunction}\"/></td>" . "<td><b> Select one of the pages below, or click <a href=\"javascript:void(0);\" onClick=\"{$jsFunction}\">Add Page</a> to create a new page</b>" . ' &nbsp; <span id="pleasewait" style="display: none"><span style="font-size: 80%; padding: 0 .2em; color: #fff; background-color: #888">Please Wait</span></span>' . ($this->target != 'AddPage' && $this->target != 'gedcom' && ($this->namespace == 'Person' || $this->namespace == 'Family') ? '<br/>' . FamilyTreeUtil::generateTreeCheckboxes($wgUser, null, true) : '') . '</td></tr></table><hr/>';
        }
        if ($numFound == 0 && count($recentDocs) == 0) {
            $output .= '<p></p><p><font size=+1>Your search did not match any documents.</font></p>';
        } else {
            // display prev..next naviagtion
            if ($start > 0) {
                $prevStart = $start - $this->rows;
                if ($prevStart < 0) {
                    $prevStart = 0;
                }
            }
            $startPlusOne = $start + 1;
            $prevNextLinks = ($start > 0 ? "<a href=\"{$selfQuery}&start={$prevStart}\">&laquo;&nbsp;Prev</a> |" : '') . " Viewing <b>{$startPlusOne}-{$end}</b> of {$numFound}" . ($end < $numFound ? " | <a href=\"{$selfQuery}&start={$end}\">Next&nbsp;&raquo;</a>" : '');
            $output .= "<div class=\"prev_next_links_top\">{$prevNextLinks}</div>\n";
            // add compare button
            if ($this->match) {
                $skin =& $wgUser->getSkin();
                $wrCompareURL = "/wiki/Special:Compare";
                $t = Title::newFromText($this->namespace . ':' . $this->pagetitle);
                $ts = '';
                if ($t) {
                    $ts = htmlspecialchars($t->getText());
                    $titleText = GedcomUtil::isGedcomTitle($this->pagetitle) ? '<b>' . htmlspecialchars($t->getPrefixedText()) . '</b>' : $skin->makeKnownLinkObj($t);
                    $compareButton = '<input type="submit" value="Compare"/> checked pages with ' . $titleText;
                }
                $output .= '<form name="compare" action="' . $wrCompareURL . '" method="post">' . $compareButton . '<input type="hidden" name="ns" value="' . $this->namespace . '"/>' . '<input type="hidden" name="compare_0" value="' . $ts . '"/>';
            }
            // generate the result list
            $docs = $response['response']['docs'];
            $highlighting = $response['highlighting'];
            $output .= '<table class="searchresulttable">';
            $pos = 0;
            foreach ($recentDocs as $doc) {
                $output .= $this->formatResult($doc, array(), -1, $this->condensedView);
            }
            foreach ($docs as $doc) {
                $pageId = $doc['PageId'];
                $hl = $highlighting[$pageId];
                $output .= $this->formatResult($doc, $hl, $pos, $this->condensedView);
                $pos++;
            }
            $output .= '</table>';
            // add compare button
            if ($this->match) {
                $output .= $compareButton . '</form>';
            }
            // display prev..next navigation
            if ($this->namespace == 'Person' || $this->namespace == 'Family') {
                $similarNamesProject = wfMsgWikiHtml('SimilarNamesProjectLink');
            } else {
                $similarNamesProject = '';
            }
            $output .= <<<END
<table style="width:99%"><tr>
<td style="width:33%">&nbsp;</td>
<td style="width:33%; text-align:center">{$prevNextLinks}</td>
<td style=" width:33%; text-align:right">{$similarNamesProject}</td>
</tr></table>
END;
        }
        return $output;
    }
Ejemplo n.º 4
0
function wrDoContentActions($action, $article)
{
    global $wgUser, $wgOut, $wgRequest;
    if ($action != 'treeUpdate' && $action != 'treeUpdateConfirm') {
        return true;
        // handle by another content action handler
    }
    if ($wgUser->isAnon()) {
        $wgOut->showErrorPage('treenologintitle', 'treenologintext');
        return false;
    }
    if (!FamilyTreeUtil::isTreePage($article->getTitle()->getNamespace(), $article->getTitle()->getDBkey())) {
        $wgOut->showErrorPage('treenonamespacetitle', 'treenonamespacetext');
        return false;
    }
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return false;
    }
    $allTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName());
    $treeOwnerIds = FamilyTreeUtil::getOwnerTrees($wgUser, $article->getTitle(), false);
    $checkedTreeIds = FamilyTreeUtil::readTreeCheckboxes($allTrees, $wgRequest);
    $ancGenerations = $wgRequest->getVal('ancestorgenerations');
    $includeAncestorChildren = $wgRequest->getCheck('includeancestorchildren');
    $descGenerations = $wgRequest->getVal('descendantgenerations');
    $wgOut->setRobotpolicy('noindex,nofollow');
    if ($action == 'treeUpdateConfirm' && ($ancGenerations == 0 && $descGenerations == 0 || count($checkedTreeIds) > 0)) {
        $dbw =& wfGetDB(DB_MASTER);
        $result = FamilyTreeUtil::updateTrees($dbw, $article->getTitle(), $article->getRevIdFetched(), $allTrees, $treeOwnerIds, $checkedTreeIds);
        if ($result) {
            $dbw->commit();
        } else {
            $dbw->rollback();
        }
        if ($ancGenerations > 0 || $descGenerations > 0) {
            $job = new AddTreePagesJob(array('trees' => join(',', $checkedTreeIds), 'user' => $wgUser->getName(), 'title' => $article->getTitle()->getPrefixedText(), 'ancGenerations' => $ancGenerations, 'includeAncestorChildren' => $includeAncestorChildren, 'descGenerations' => $descGenerations));
            $job->insert();
            $treesUpdatedMsg = 'treesupdatedtextdeferred';
        } else {
            $treesUpdatedMsg = 'treesupdatedtext';
        }
        $wgOut->setPagetitle(wfMsg('treesupdatedtitle'));
        $wgOut->addWikiText(wfMsg($treesUpdatedMsg));
        $wgOut->returnToMain(true, $article->getTitle()->getPrefixedText());
    } else {
        if (count($allTrees) == 0) {
            $wgOut->showErrorPage('treenonetitle', 'treenonetext');
        } else {
            // show form
            $wgOut->setPagetitle(wfMsg('treeupdatetitle'));
            if ($action == 'treeUpdateConfirm') {
                $wgOut->addHTML('<font color="red">Please check the box next to the tree(s) you want to add the pages to.</font>');
            }
            $wgOut->addWikiText('==Trees==');
            $wgOut->addWikiText(wfMsg('treeupdatetext'));
            // TODO show form
            $action = $article->getTitle()->escapeLocalURL('action=treeUpdateConfirm');
            $wgOut->addHTML(<<<END
<form id="treeUpdate" method="post" action="{$action}" enctype="multipart/form-data">
END
);
            $wgOut->addHTML(FamilyTreeUtil::generateTreeCheckboxes($wgUser, $article->getTitle(), false, $allTrees, $treeOwnerIds));
            if ($article->getTitle()->getNamespace() == NS_PERSON || $article->getTitle()->getNamespace() == NS_FAMILY) {
                $wgOut->addWikiText('==Include relatives==');
                $wgOut->addWikiText(":'''''Warning''': including relatives can add potentially many people to your tree and to your watchlist.''");
                $wgOut->addWikiText(':Add the following relatives to the checked trees.');
                $options = array();
                for ($i = 0; $i <= 20; $i++) {
                    $options["{$i}"] = $i;
                }
                $ancGenerations = StructuredData::addSelectToHtml(0, 'ancestorgenerations', $options, 0);
                $options = array();
                for ($i = 0; $i <= 5; $i++) {
                    $options["{$i}"] = $i;
                }
                $descGenerations = StructuredData::addSelectToHtml(0, 'descendantgenerations', $options, 0);
                $wgOut->addHTML(<<<END
<dl><dd>Include ancestors for {$ancGenerations} generations
\t<dl><dd><input type="checkbox" name="includeancestorchildren"/>Also include ancestors' children</dd></dl></dd>
<dd>&nbsp;</dd>
<dd>Include descendants for {$descGenerations} generations</dd>
</dl>
END
);
            }
            $updateButton = array('id' => 'wrTreeUpdate', 'name' => 'wrTreeUpdate', 'type' => 'submit', 'value' => wfMsg('treeupdatebutton'), 'title' => wfMsg('treeupdatebuttontip'));
            $wgOut->addHTML(wfElement('input', $updateButton, ''));
            $wgOut->addHTML("</form>\n");
        }
    }
    return false;
    // stop processing
}