/** * Creates sidebar HTML for indicating concepts which exist * in multiple datasets, and providing a link to add new * mappings. * * Potential refactor candidate! */ protected function getConceptPanel() { global $wgTitle, $wgUser, $wdShowCopyPanel; $active = true; # wrong place, but hey $dmId = $this->getDefinedMeaningId(); $dc = wdGetDataSetContext(); $ow_conceptpanel = wfMsgSc( "concept_panel" ); $html = "<div class=\"dataset-panel\">"; ; $html .= "<table border=\"0\"><tr><th class=\"dataset-panel-heading\">$ow_conceptpanel</th></tr>"; $sk = $wgUser->getSkin(); $meanings = getDefinedMeaningDataAssociatedByConcept( $dmId, $dc ); if ( $meanings ) { foreach ( $meanings as $dm ) { $dataset = $dm->getDataset(); $active = ( $dataset->getPrefix() == $dc->getPrefix() ); $name = $dataset->fetchName(); $prefix = $dataset->getPrefix(); $class = $active ? 'dataset-panel-active' : 'dataset-panel-inactive'; $slot = $active ? "$name" : $sk->makeLinkObj( $dm->getTitleObject(), $name, "dataset=$prefix" ); $html .= "<tr><td class=\"$class\">$slot</td></tr>"; } } else { $name = $dc->fetchName(); $html .= "<tr><td class=\"dataset-panel-active\">$name</td></tr>"; } $cmtitle = Title::newFromText( "Special:ConceptMapping" ); $titleText = $wgTitle->getPrefixedURL(); $cmlink = $sk->makeLinkObj( $cmtitle, "<small>" . wfMsgSc( "add_concept_link" ) . "</small>", "set_$dc=$dmId&suppressWarnings=true" ); $html .= "<tr><td>$cmlink</td></tr>\n"; if ( $wdShowCopyPanel ) { $html .= "<tr><td>" . $this->getCopyPanel() . "<td><tr>"; } $html .= "</table>\n"; $html .= "</div>\n"; return $html; }
/** automatically redirects to another page. * make sure you haven't used $wgOut before calling this! */ protected function autoredir() { global $wgOut, $wgRequest; $dmid_dirty = $wgRequest->getText( "dmid" ); $dc1_dirty = $wgRequest->getText( "dc1" ); $dc2_dirty = $wgRequest->getText( "dc2" ); # Where should we redirect to? $meanings = getDefinedMeaningDataAssociatedByConcept( $dmid_dirty, $dc1_dirty ); $targetdmm = $meanings[$dc2_dirty]; $title = $targetdmm->getTitleObject(); $url = $title->getLocalURL( "dataset=$dc2_dirty&action=edit" ); # do the redirect $wgOut->disable(); header( 'Location: ' . $url ); # $wgOut->addHTML("<a href=\"$url\">$url</a>"); }