User:Otterstedt/Extensions/CalcLimitingMagnitude

 
A proposal to move this page to MediaWiki.org was rejected.

Special:CalcLimitingMagnitude is the first of a set of mediawiki extensions I plan to write for my Amateur Telescope Making Wiki. It shows a form, where the user can type in his telescop aperture. After pushing "Berechnen" it will calculate an approximated limiting magnitude for the given telescope. The calculations are quite simple. Beneath the form the are some references links to the used formulas and some "see also" links.

You'll find the Special Page in action at this location. I would appreciate any error messages and suggestions, because this is my first special page ;-)

Otterstedt 11:32, 3 March 2006 (UTC)

See also

edit

Sourcecode

edit
<?php

/* --------------------------------------------------------------
 * File:
 *   SpecialCalcLimitingMagnitude.php
 *
 * Summary:
 *  Special Page for Mediawiki 1.5.x
 *  Calculates Limiting Magnitude by Telescope Aperture
 *
 * Author:
 *   Heiner Otterstedt
 *
 * Todo:
 *   additional languages
 *
 * --------------------------------------------------------------
 */

$wgExtensionFunctions[] = "wfExtensionSpecialCalcLimitingMagnitude";

global $wgTitle;
global $IP;
require_once( $IP . '/includes/SpecialPage.php' );

function wfExtensionSpecialCalcLimitingMagnitude()
{
  global $wgMessageCache;
  $wgMessageCache->addMessages(array('calclimitingmagnitude' => 'Calculate Limiting Magnitude'));
  // TODO: No idea how to addMessages this: 'Berechnung der visuellen Grenzgröße' because of the german umlauts
  
  SpecialPage::addPage( new CalcLimitingMagnitudeSpecialPage( ) );
}

class CalcLimitingMagnitudeSpecialPage extends SpecialPage
{
  function CalcLimitingMagnitudeSpecialPage()
  {
    SpecialPage::SpecialPage( 'CalcLimitingMagnitude' );
  }

  function execute( $params )
  {
    global $wgOut, $wgUser;
    global $wgRequest;

    $this->setHeaders();

    $erg = $wgRequest->getVal( 'diameter' );
    if($erg == '' || $erg <= 0) $erg = 250;
    $numerg1 = 8.5 + 2.5 * log10(($erg * $erg * 0.7) / (7*7) );
    $numerg2 = 7.5 + 5 * log10($erg/10);
    $numerg1 = round($numerg1,2);
    $numerg2 = round($numerg2,2);

    //Retrieving the URL for the action
    $titleObj = Title::makeTitle( NS_SPECIAL, 'CalcLimitingMagnitude' );
    $action = $titleObj->escapeLocalURL();

    // Output
    $wgOut->addHTML    ('<div id="calculatortable">');
    $wgOut->addHTML    ('<table border="1" cellspacing="0" cellpadding="3">'."\n");
    $wgOut->addHTML    (  "<tr>\n");
    $wgOut->addHTML    (    '<td colspan="2">'."\n");
    $wgOut->addWikiText(      "<h3>Berechnung der Grenzgröße aus der Teleskopöffnung</h3>\n");
    $wgOut->addHTML    (    "</td>\n");
    $wgOut->addHTML    (  "</tr>\n");
    $wgOut->addHTML    (  "<tr>\n");
    $wgOut->addHTML    (    '<td valign="top" align="left">'."\n");
    $wgOut->addHTML    (      '<form method="post" enctype="multipart/form-data" action="'.$action.'">'."\n");
    $wgOut->addWikiText(      "Teleskopöffnung<br>\n");
    $wgOut->addHTML    (      '<input type="text" name="diameter" size="7" value="'.$erg.'" />mm<br />'."\n");
    $wgOut->addHTML    (      '<input type="submit" value="Berechnen" name="calc" /><br />'."\n");
    $wgOut->addHTML    (      '</form>'."\n");
    $wgOut->addHTML    (    '</td>'."\n");
    $wgOut->addHTML    (    '<td valign="top" align="left">'."\n");
    $wgOut->addWikiText(      "Visuelle Grenzgröße (Formel 1); $numerg1 [[mag]]<br />\n");
    $wgOut->addWikiText(      "Visuelle Grenzgröße (Formel 2): $numerg2 [[mag]]<br />\n");
    $wgOut->addHTML    (    '</td>'."\n");
    $wgOut->addHTML    (  '</tr>'."\n");
    $wgOut->addHTML    ("</table></div>\n");
    $wgOut->addHTML    ("<br />\n");
    $wgOut->addHTML    ("<br />\n");
    $wgOut->addWikiText("==Referenzen==\n");
    $wgOut->addWikiText(": '''Formel 1'''\n");
    $wgOut->addWikiText(": [[mag]] = M<sub>eye</sub> + 2.5 * log(D<sup>2</sup> * t / D<sub>eye</sub><sup>2</sup> )\n");
    $wgOut->addWikiText(": Quellen:\n");
    $wgOut->addWikiText(":: http://astro.umsystem.edu/atm/ARCHIVES/APR00/msg00692.html\n");
    $wgOut->addWikiText(":: http://www.shatters.net/forum/viewtopic.php?t=940\n");

    $wgOut->addWikiText(": '''Formel 2'''\n");
    $wgOut->addWikiText(": [[mag]] = 7.5 + 5 * log(D/10)\n");
    $wgOut->addWikiText(": Quelle:\n");
    $wgOut->addWikiText(":: http://www.utahskies.org/tips/terminology.htm\n");

    $wgOut->addWikiText("==Siehe auch==\n");
    $wgOut->addWikiText("*[[Berechnung der visuellen Grenzgröße aus der Teleskopöffnung]]\n");
    $wgOut->addWikiText("*[[Formelsammlung]]\n");
    $wgOut->addWikiText("*[[Formelzeichen]]\n");
  }
}

?>