Exemplo n.º 1
0
/**
 * Callback function for rendering edit fields
 * @return bool must return true or other hooks don't get called
 */
function renderImageEditFields(&$editPage)
{
    global $wgOut, $wgScriptPath;
    $ns = $editPage->mTitle->getNamespace();
    if ($ns == NS_IMAGE && !$editPage->section) {
        $image = new Fotonotes($editPage->mTitle);
        // get notes
        $notes = '';
        $start = stripos($editPage->textbox1, "<fotonotes>");
        if ($start !== false) {
            $start += strlen("<fotonotes>");
            $end = stripos($editPage->textbox1, "</fotonotes>", $start);
            if ($end !== false) {
                $notes = substr($editPage->textbox1, $start, $end - $start);
            }
        }
        $wgOut->addHTML($image->renderEditableImage($notes));
        $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/fnclientwiki.yui.1.js\"></script>");
    }
    return true;
}
Exemplo n.º 2
0
    /**
     * Create edit fields from xml property
     */
    protected function toEditFields(&$textbox1)
    {
        global $wgStylePath, $wgScriptPath, $wgOut, $wgUser, $wgRequest;
        if (!$this->title->exists()) {
            return '<p><font color=red>Image does not exist.  You must</font> <a href="/wiki/Special:Upload"><b>upload it.</b></a></p>';
        }
        // add javascript functions
        $wgOut->addScript("<script type='text/javascript' src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
        if ($wgRequest->getVal('action') != 'submit') {
            $wgOut->addScript("<script type='text/javascript' src=\"{$wgScriptPath}/fnclientwiki.yui.1.js\"></script>");
        }
        $wgOut->addScript("<script type='text/javascript' src=\"{$wgScriptPath}/image.1.js\"></script>");
        $wgOut->addScript("<script type='text/javascript' src=\"{$wgStylePath}/common/upload.2.js\"></script>");
        $date = '';
        $place = '';
        $copyright = '';
        $license = '';
        $notes = '';
        $invalidStyle = ' style="background-color:#fdd;"';
        $licenseStyle = '';
        $people = array();
        $families = array();
        if (!isset($this->xml)) {
            $this->addWhatLinksHere($people, $families);
        } else {
            $date = htmlspecialchars((string) $this->xml->date);
            $place = htmlspecialchars((string) $this->xml->place);
            $people = StructuredData::getTitlesAsArray($this->xml->person);
            $families = StructuredData::getTitlesAsArray($this->xml->family);
            $copyright = htmlspecialchars((string) $this->xml->copyright_holder);
            $license = (string) $this->xml->license;
            if (isset($this->xml->note)) {
                foreach ($this->xml->note as $note) {
                    $title = htmlspecialchars((string) $note['title']);
                    $content = htmlspecialchars((string) $note);
                    $notes .= '<note left="' . (string) $note['left'] . '" top="' . (string) $note['top'] . '" right="' . (string) $note['right'] . '" bottom="' . (string) $note['bottom'] . '" title="' . $title . "\">{$content}</note>\n";
                }
            }
        }
        // get license options
        $licenses = new Licenses();
        $licenseLabel = wfMsgHtml('license');
        $sk = $wgUser->getSkin();
        $licenseHelpUrl = $sk->makeInternalOrExternalUrl(wfMsgForContent('licensehelppage'));
        $licenseHelp = '<a target="helpwindow" href="' . $licenseHelpUrl . '">' . htmlspecialchars(wfMsg('licensehelp')) . '</a>';
        $nolicense = wfMsgHtml('nolicense');
        $licenseshtml = $licenses->getHTML();
        if ($license) {
            $licenseshtml = preg_replace('$value="' . StructuredData::protectRegexSearch($license) . '"$', 'value="' . StructuredData::protectRegexReplace($license) . '" selected="selected"', $licenseshtml);
        }
        $result = '';
        // add fotonotes
        $fn = new Fotonotes($this->title);
        $result .= $fn->renderEditableImage(isset($this->xml) ? $this->xml->note : null) . '<br>';
        // error messages
        if (!SDImage::isValidLicense($license)) {
            $licenseStyle = $invalidStyle;
            $result .= "<p><font color=red>You must select a license</font></p>";
        }
        // add fields
        $personTbl = $this->addPageInput($people, 'person');
        $familyTbl = $this->addPageInput($families, 'family');
        $notes = htmlspecialchars($notes);
        $result .= <<<END
<input type="hidden" id="notesField" name="notes" value="{$notes}"/>
<table border=0>
<tr><td>&nbsp;</td><td><b>License and copyright</b></td></tr>
<tr><td align='right'><label for='wpLicense'>{$licenseLabel} (&nbsp;{$licenseHelp}&nbsp;):</label></td>
\t<td align='left'><select name='license' id='wpLicense' tabindex='1' onchange='licenseSelectorCheck()'>
\t\t<option value=''>{$nolicense}</option>{$licenseshtml}</select></td></tr>
<tr><td align='right'><label for="copyright_holder">Name of copyright holder:</label></td><td align='left'><input tabindex="1" name="copyright_holder" value="{$copyright}" size="30"/></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
<tr><td>&nbsp;</td><td><b>Time place and people</td></tr>
<tr><td align='right'><label for="date">Image date:</label></td><td align='left'><input tabindex="1" name="date" value="{$date}" size="15"/></td></tr>
<tr><td align='right'><label for="place">Place:</label></td><td align='left'><input class="place_input" tabindex="1" name="place" value="{$place}" size="30"/></td></tr>
<tr><td align='right' valign='top'>Person page:</td><td align='left'>{$personTbl}</td></tr>
<tr><td>&nbsp;</td><td align='left'><a id='person_link' href='javascript:void(0)' onClick='addImagePage("person"); return preventDefaultAction(event);'>Add another person</a></td></tr>
<tr><td align='right' valign='top'>Family page:</td><td align='left'>{$familyTbl}</td></tr>
<tr><td>&nbsp;</td><td align='left'><a id='family_link' href='javascript:void(0)' onClick='addImagePage("family"); return preventDefaultAction(event);'>Add another family</a></td></tr>
</table><h2>Text</h2>
END;
        return $result;
    }