Index: ChemFunctions.i18n.php
===================================================================
--- ChemFunctions.i18n.php (revision 17146)
+++ ChemFunctions.i18n.php (working copy)
@@ -26,7 +26,8 @@
* ECNumber = The EC Number for the compound
*/
-$wgChemFunctions_ChemicalIdentifiers = array ('CAS', 'Formula', 'Name', 'EINECS', 'CHEBI', 'PubChem', 'SMILES', 'InChI', 'ATCCode', 'DrugBank', 'KEGG', 'ECNumber', 'RTECS');
+$wgChemFunctions_Parameters = array ('CAS', 'Formula', 'Name', 'EINECS', 'CHEBI', 'PubChem', 'SMILES', 'InChI', 'ATCCode', 'DrugBank', 'KEGG', 'ECNumber', 'RTECS');
+$wgChemFunctions_Prefix = "ChemFunctions";
# Begin internationalisation
@@ -38,8 +39,11 @@
$wgChemFunctions_Messages['en'] = array(
'chemicalsources' => 'Chemical sources',
- 'ChemFunctions_Chemicalsources' => 'Chemical sources',
- 'ChemFunctions_ChemicalsourcesPage' => 'Chemical sources',
+ 'ChemFunctions_ListPage' => 'Chemical sources',
+ 'ChemFunctions_SearchExplanation' => '',
+ 'ChemFunctions_DataList' => 'Below is a list of links to sites that may provide information about the chemical substance you are looking for.
+ * Compound $MIXCASNameFormula at NIST
+ * MSDS at the Oxford University (UK) (not searchable)
',
'ChemFunctions_CAS' => 'CAS number',
'ChemFunctions_EINECS' => 'Einecs',
'ChemFunctions_CHEBI' => 'CHEBI',
@@ -52,17 +56,16 @@
'ChemFunctions_DrugBank' => 'DrugBank',
'ChemFunctions_ECNumber' => 'ECNumber',
'ChemFunctions_Formula' => 'Formula',
- 'ChemFunctions_Name' => 'IUPAC Name',
- 'ChemFunctions_SearchExplanation' => '',
- 'ChemFunctions_ChemicalDataList' => 'Below is a list of links to sites that may provide information about the chemical substance you are looking for.
- * Compound $MIXCASNameFormula at NIST
- * MSDS at the Oxford University (UK) (not searchable)
'
+ 'ChemFunctions_Name' => 'IUPAC Name'
);
$wgChemFunctions_Messages['de'] = array(
'chemicalsources' => 'Chemische Quellen',
- 'ChemFunctions_Chemicalsources' => 'Chemische Quellen',
- 'ChemFunctions_ChemicalsourcesPage' => 'Chemische Quellen',
+ 'ChemFunctions_ListPage' => 'Chemische Quellen',
+ 'ChemFunctions_SearchExplanation' => '',
+ 'ChemFunctions_DataList' => 'Nachfolgend finden Sie Links zu Seiten, die eventuell Informationen über chemische Substanzen anbieten, nach denen Sie suchen:
+ * Verbindung $MIXCASNameFormula auf NIST
+ * MSDS an der Oxford University (UK) (nicht durchsuchbar)
',
'ChemFunctions_CAS' => 'CAS Nummer',
'ChemFunctions_EINECS' => 'Einecs',
'ChemFunctions_CHEBI' => 'CHEBI',
@@ -75,17 +78,16 @@
'ChemFunctions_DrugBank' => 'DrugBank',
'ChemFunctions_ECNumber' => 'ECNumber',
'ChemFunctions_Formula' => 'Formula',
- 'ChemFunctions_Name' => 'IUPAC Name',
- 'ChemFunctions_SearchExplanation' => '',
- 'ChemFunctions_ChemicalDataList' => 'Nachfolgend finden Sie Links zu Seiten, die eventuell Informationen über chemische Substanzen anbieten, nach denen Sie suchen:
- * Verbindung $MIXCASNameFormula auf NIST
- * MSDS an der Oxford University (UK) (nicht durchsuchbar)
'
+ 'ChemFunctions_Name' => 'IUPAC Name'
);
$wgChemFunctions_Messages['nl'] = array(
'chemicalsources' => 'Chemicaliën bronnen',
- 'ChemFunctions_Chemicalsources' => 'Chemicaliën bronnen',
- 'ChemFunctions_ChemicalsourcesPage' => 'Chemicaliën bronnen',
+ 'ChemFunctions_ListPage' => 'Chemicaliën bronnen',
+ 'ChemFunctions_SearchExplanation' => '',
+ 'ChemFunctions_DataList' => 'Hieronder staat een lijst van pagina\'s, die meer informatie over de chemische verbinding kunnen verschaffen.
+ * Verbinding $MIXCASNameFormula op de pagina van het NIST
+ * MSDS op de pagina van de Oxford University (UK) (geen zoekresultaten)
',
'ChemFunctions_CAS' => 'CAS nummer',
'ChemFunctions_EINECS' => 'Einecs',
'ChemFunctions_CHEBI' => 'CHEBI',
@@ -98,17 +100,16 @@
'ChemFunctions_DrugBank' => 'DrugBank',
'ChemFunctions_ECNumber' => 'EC Nummer',
'ChemFunctions_Formula' => 'Formula',
- 'ChemFunctions_Name' => 'IUPAC Naam',
- 'ChemFunctions_SearchExplanation' => '',
- 'ChemFunctions_ChemicalDataList' => 'Hieronder staat een lijst van pagina\'s, die meer informatie over de chemische verbinding kunnen verschaffen.
- * Verbinding $MIXCASNameFormula op de pagina van het NIST
- * MSDS op de pagina van de Oxford University (UK) (geen zoekresultaten)
'
+ 'ChemFunctions_Name' => 'IUPAC Naam'
);
$wgChemFunctions_Messages['sk'] = array(
'chemicalsources' => 'Chemické zdroje',
- 'ChemFunctions_Chemicalsources' => 'Chemické zdroje',
- 'ChemFunctions_ChemicalsourcesPage' => 'Chemické zdroje',
+ 'ChemFunctions_ListPage' => 'Chemické zdroje',
+ 'ChemFunctions_SearchExplanation' => '',
+ 'ChemFunctions_DataList' => 'Nižšie je zoznam odkazov na stránky, ktoré môžu poskytnúť informácie o chemikálii, ktorú používate.
+ * Zlúčenina $MIXCASNameFormula na NIST
+ * MSDS na Oxford University (UK) (nedá sa vyhľadávať)
',
'ChemFunctions_CAS' => 'CAS číslo',
'ChemFunctions_EINECS' => 'Einecs',
'ChemFunctions_CHEBI' => 'CHEBI',
@@ -121,11 +122,7 @@
'ChemFunctions_DrugBank' => 'DrugBank',
'ChemFunctions_ECNumber' => 'ECNumber',
'ChemFunctions_Formula' => 'Formula',
- 'ChemFunctions_Name' => 'IUPAC názov',
- 'ChemFunctions_SearchExplanation' => '',
- 'ChemFunctions_ChemicalDataList' => 'Nižšie je zoznam odkazov na stránky, ktoré môžu poskytnúť informácie o chemikálii, ktorú používate.
- * Zlúčenina $MIXCASNameFormula na NIST
- * MSDS na Oxford University (UK) (nedá sa vyhľadávať)
'
+ 'ChemFunctions_Name' => 'IUPAC názov'
);
?>
Index: SpecialChemicalsources.php
===================================================================
--- SpecialChemicalsources.php (revision 17146)
+++ SpecialChemicalsources.php (working copy)
@@ -1,26 +1,15 @@
'Special:Chemicalsources.php',
+ 'name' => 'Special:Chemicalsources',
'description' => 'Special Page for Chemical sources',
'author' => 'Dirk Beetstra',
'url' => 'http://meta.wikimedia.org/wiki/Chemistry'
);
+# Includes
+global $IP;
+require_once ("$IP/includes/SpecialPage.php");
+require_once( 'ChemFunctions.i18n.php' );
+
+# Add the page
function wfSpecialChemicalsources () {
- global $IP, $wgMessageCache, $wgServer, $wgChemFunctions_Messages, $wgChemFunctions_ChemicalIdentifiers;
+ SpecialPage::addPage( new SpecialChemicalsources );
+}
- require_once( 'ChemFunctions.i18n.php' );
- require_once ("$IP/includes/SpecialPage.php");
+class SpecialChemicalsources extends SpecialPage {
+ var $Parameters, $Prefix;
- global $wgMessageCache, $wgChemFunctions_Messages;
- foreach( $wgChemFunctions_Messages as $key => $value ) {
- $wgMessageCache->addMessages( $wgChemFunctions_Messages[$key], $key );
+ function SpecialChemicalsources() {
+ global $wgChemFunctions_Parameters, $wgChemFunctions_Prefix;
+ $this->Parameters = $wgChemFunctions_Parameters;
+ $this->Prefix = $wgChemFunctions_Prefix;
+
+ global $wgMessageCache, $wgChemFunctions_Messages;
+ foreach( $wgChemFunctions_Messages as $key => $value ) {
+ $wgMessageCache->addMessages( $wgChemFunctions_Messages[$key], $key );
+ }
+
+ SpecialPage::SpecialPage( 'Chemicalsources' );
+ $this->includable( false );
}
- class SpecialChemicalsources extends SpecialPage {
+ function execute ($par) {
+ global $wgOut, $wgRequest, $wgContLang, $wgScript, $wgServer, $wgTitle;
- /**
- * Constructor
- */
- function SpecialChemicalsources() {
- SpecialPage::SpecialPage( 'Chemicalsources' );
- $this->includable( false );
- }
+ $wgOut->setPagetitle( wfMsg("chemicalsources") );
- function execute ($par) {
- global $wgOut, $wgRequest, $wgContLang, $wgScript, $wgServer, $wgTitle, $wgChemFunctionChemIdent;
+ $Params = $wgRequest->getValues();
- $wgOut->setPagetitle( wfMsg('ChemFunctions_Chemicalsources') );
- $Params = $wgRequest->getValues();
- $ParamsCheck = "";
- global $wgChemFunctions_ChemicalIdentifiers;
- foreach ($wgChemFunctions_ChemicalIdentifiers as $key) {
- if ( isset( $Params [$key] ) )
- $ParamsCheck .= $Params [$key];
- }
- if ($ParamsCheck) {
- $transParams = $this->TransposeAndCheckParams($Params);
- $this->OutputChemicalSources($transParams);
- } else {
- $Params = $this->getParams();
- }
+ $ParamsCheck = "";
+ foreach ($this->Parameters as $key) {
+ if ( isset( $Params [$key] ) )
+ $ParamsCheck .= $Params [$key];
}
- function OutputChemicalSources($transParams) {
-#Create the actual page
- global $wgOut;
- # First, see if we have a custom list setup in
- # [[Wikipedia:Chemical sources]] or equivalent.
- $bstitle = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'ChemFunctions_ChemicalsourcesPage' ) );
- if( $bstitle ) {
- $revision = Revision::newFromTitle( $bstitle );
- if( $revision ) {
- $bstext = $revision->getText();
- if( $bstext ) {
- $bstext = strtr($bstext, $transParams);
- $wgOut->addWikiText( $bstext );
- }
- } else {
- $bstext = wfMsg( 'ChemFunctions_ChemicalDataList' );
+ if ($ParamsCheck) {
+ $transParams = $this->TransposeAndCheckParams($Params);
+ $this->OutputChemicalSources($transParams);
+ } else {
+ $Params = $this->getParams();
+ }
+ }
+
+ #Create the actual page
+ function OutputChemicalSources($transParams) {
+ global $wgOut;
+
+ # First, see if we have a custom list setup
+ $bstitle = Title::makeTitleSafe( NS_PROJECT, wfMsg( $this->Prefix . '_ListPage' ) );
+ if( $bstitle ) {
+ $revision = Revision::newFromTitle( $bstitle );
+ if( $revision ) {
+ $bstext = $revision->getText();
+ if( $bstext ) {
$bstext = strtr($bstext, $transParams);
- $wgOut->addHTML( $bstext );
+ $wgOut->addWikiText( $bstext );
}
+ } else {
+ $bstext = wfMsg( $Prefix . '_DataList' );
+ $bstext = strtr($bstext, $transParams);
+ $wgOut->addHTML( $bstext );
}
}
+ }
- function TransposeAndCheckParams($Params) {
-# Check the parameters supplied
-# Make the mixed parameters
-# and put them into the transpose matrix.
- if ( isset( $Params['CAS'] ) )
- $Params['CAS'] = preg_replace( '/[^0-9\-]/', "", $Params['CAS'] );
- else $Params['CAS'] = '';
- if ( isset( $Params['EINECS'] ) )
- $Params['EINECS'] = preg_replace( '/[^0-9\-]/', "", $Params['EINECS'] );
- else $Params['EINECS'] = '';
- if ( isset( $Params['CHEBI'] ) )
- $Params['CHEBI'] = preg_replace( '/[^0-9\-]/', "", $Params['CHEBI'] );
- else $Params['CHEBI'] = '';
- if ( isset( $Params['PubChem'] ) )
- $Params['PubChem'] = preg_replace( '/[^0-9\-]/', "", $Params['PubChem'] );
- /*
- if ( isset( $Params['SMILES'] ) )
- $Params['SMILES'] = $Params['SMILES'];
- else $Params['SMILES'] = '';
- if ( isset( $Params['InChI'] ) )
- $Params['InChI'] = $Params['InChI'];
- else $Params['InChI'] = '';
- */
- if ( isset( $Params['ATCCode'] ) )
- $Params['ATCCode'] = preg_replace( '/[^0-9\-]/', "", $Params['ATCCode'] );
- else $Params['ATCCode'] = '';
- if ( isset( $Params['KEGG'] ) )
- $Params['KEGG'] = preg_replace( '/[^C0-9\-]/', "", $Params['KEGG'] );
- else $Params['KEGG'] = '';
- if ( isset( $Params['RTECS'] ) )
- $Params['RTECS'] = preg_replace( '/[^0-9\-]/', "", $Params['RTECS'] );
- else $Params['RTECS'] = '';
- if ( isset( $Params['ECNumber'] ) )
- $Params['ECNumber'] = preg_replace( '/[^0-9\-]/', "", $Params['ECNumber'] );
- else $Params['ECNumber'] = '';
- if ( isset( $Params['Drugbank'] ) )
- $Params['Drugbank'] = preg_replace( '/[^0-9\-]/', "", $Params['Drugbank'] );
- else $Params['Drugbank'] = '';
- if ( isset( $Params['Formula'] ) )
- $Params['Formula'] = preg_replace( "<,*?>", "", $Params['Formula'] );
- else $Params['Formula'] = '';
- if ( isset( $Params['Name'] ) )
- $Params['Name'] = str_replace( " ", "%20", $Params['Name'] );
- else $Params['Name'] = '';
+ # Check the parameters supplied, make the mixed parameters, and put them into the transpose matrix.
+ function TransposeAndCheckParams($Params) {
+ if ( isset( $Params['CAS'] ) )
+ $Params['CAS'] = preg_replace( '/[^0-9\-]/', "", $Params['CAS'] );
+ else $Params['CAS'] = '';
+ if ( isset( $Params['EINECS'] ) )
+ $Params['EINECS'] = preg_replace( '/[^0-9\-]/', "", $Params['EINECS'] );
+ else $Params['EINECS'] = '';
+ if ( isset( $Params['CHEBI'] ) )
+ $Params['CHEBI'] = preg_replace( '/[^0-9\-]/', "", $Params['CHEBI'] );
+ else $Params['CHEBI'] = '';
+ if ( isset( $Params['PubChem'] ) )
+ $Params['PubChem'] = preg_replace( '/[^0-9\-]/', "", $Params['PubChem'] );
+ /*
+ if ( isset( $Params['SMILES'] ) )
+ $Params['SMILES'] = $Params['SMILES'];
+ else $Params['SMILES'] = '';
+ if ( isset( $Params['InChI'] ) )
+ $Params['InChI'] = $Params['InChI'];
+ else $Params['InChI'] = '';
+ */
+ if ( isset( $Params['ATCCode'] ) )
+ $Params['ATCCode'] = preg_replace( '/[^0-9\-]/', "", $Params['ATCCode'] );
+ else $Params['ATCCode'] = '';
+ if ( isset( $Params['KEGG'] ) )
+ $Params['KEGG'] = preg_replace( '/[^C0-9\-]/', "", $Params['KEGG'] );
+ else $Params['KEGG'] = '';
+ if ( isset( $Params['RTECS'] ) )
+ $Params['RTECS'] = preg_replace( '/[^0-9\-]/', "", $Params['RTECS'] );
+ else $Params['RTECS'] = '';
+ if ( isset( $Params['ECNumber'] ) )
+ $Params['ECNumber'] = preg_replace( '/[^0-9\-]/', "", $Params['ECNumber'] );
+ else $Params['ECNumber'] = '';
+ if ( isset( $Params['Drugbank'] ) )
+ $Params['Drugbank'] = preg_replace( '/[^0-9\-]/', "", $Params['Drugbank'] );
+ else $Params['Drugbank'] = '';
+ if ( isset( $Params['Formula'] ) )
+ $Params['Formula'] = preg_replace( "<,*?>", "", $Params['Formula'] );
+ else $Params['Formula'] = '';
+ if ( isset( $Params['Name'] ) )
+ $Params['Name'] = str_replace( " ", "%20", $Params['Name'] );
+ else $Params['Name'] = '';
+ # Create some new from old ones
- $TEMPCASNAMEFORMULA = $Params["CAS"];
- if(empty ($TEMPCASNAMEFORMULA)){
- $TEMPCASNAMEFORMULA = $Params["Formula"];
- }
- if(empty ($TEMPCASNAMEFORMULA)){
- $TEMPCASNAMEFORMULA = $Params["Name"];
- }
+ $TEMPCASNAMEFORMULA = $Params["CAS"];
+ if(empty ($TEMPCASNAMEFORMULA)){
+ $TEMPCASNAMEFORMULA = $Params["Formula"];
+ }
+ if(empty ($TEMPCASNAMEFORMULA)){
+ $TEMPCASNAMEFORMULA = $Params["Name"];
+ }
- $TEMPNAMEFORMULA = $Params["Name"];
- if(empty ($TEMPNAMEFORMULA)){
- $TEMPNAMEFORMULA = $Params["Formula"];
- }
+ $TEMPNAMEFORMULA = $Params["Name"];
+ if(empty ($TEMPNAMEFORMULA)){
+ $TEMPNAMEFORMULA = $Params["Formula"];
+ }
- $TEMPCASFORMULA = $Params["CAS"];
- if(empty ($TEMPCASFORMULA)){
- $TEMPCASFORMULA = $Params["Formula"];
- }
+ $TEMPCASFORMULA = $Params["CAS"];
+ if(empty ($TEMPCASFORMULA)){
+ $TEMPCASFORMULA = $Params["Formula"];
+ }
- $TEMPCASNAME = $Params["CAS"];
- if(empty ($TEMPCASNAME)){
- $TEMPCASNAME = $Params["Name"];
- }
-
- $transParams = array("\$MIXCASNameFormula" => $TEMPCASNAMEFORMULA,
- "\$MIXCASName" => $TEMPCASNAME,
- "\$MIXCASFormula" => $TEMPCASFORMULA,
- "\$MIXNameFormula" => $TEMPNAMEFORMULA);
- global $wgChemFunctions_ChemicalIdentifiers;
- foreach ($wgChemFunctions_ChemicalIdentifiers as $key) {
- if ( isset( $Params[$key] ) )
- $transParams["\$" . $key] = $Params[$key] ;
- }
- return $transParams;
+ $TEMPCASNAME = $Params["CAS"];
+ if(empty ($TEMPCASNAME)){
+ $TEMPCASNAME = $Params["Name"];
}
+ # Put the parameters into the transpose array:
- function getParams() {
-#If no parameters supplied, get them!
- global $wgTitle, $wgOut; $wfMsg;
- $action = $wgTitle->escapeLocalUrl();
- $go = htmlspecialchars( wfMsg( "go" ) );
-
- global $wgChemFunctions_ChemicalIdentifiers;
- $wgOut->addWikitext ( wfMsg('ChemFunctions_SearchExplanation'));
- $wgOut->addHTML("
");
- foreach ($wgChemFunctions_ChemicalIdentifiers as $key) {
- $this->GetParam_Row("ChemFunctions_" . $key, $key, $action, $go);
+ $transParams = array("\$MIXCASNameFormula" => $TEMPCASNAMEFORMULA,
+ "\$MIXCASName" => $TEMPCASNAME,
+ "\$MIXCASFormula" => $TEMPCASFORMULA,
+ "\$MIXNameFormula" => $TEMPNAMEFORMULA);
+ foreach ($this->Parameters as $key) {
+ if ( isset( $Params[$key] ) ) {
+ $transParams["\$" . $key] = $Params[$key] ;
+ } else {
+ $transParams["\$" . $key] = "" ;
}
- $wgOut->addHTML(" |
");
}
+ return $transParams;
+ }
- function GetParam_Row($p, $q, $action, $go) {
-#Creates a table row
- global $wgOut;
- $wgOut->addHTML ( wfMsg( $p ) . ": ");
- $wgOut->addHTML("
-
- | ");
- $wgOut->addHTML("");
- }
+ #If no parameters supplied, get them!
+ function getParams() {
+ global $wgTitle, $wgOut; $wfMsg;
+ $action = $wgTitle->escapeLocalUrl();
+ $go = htmlspecialchars( wfMsg( "go" ) );
+ $wgOut->addWikitext ( wfMsg($this->Prefix . '_SearchExplanation'));
+ $wgOut->addHTML("");
+ foreach ($this->Parameters as $key) {
+ $this->GetParam_Row($this->Prefix . "_" . $key, $key, $action, $go);
+ }
+ $wgOut->addHTML(" | ");
}
- SpecialPage::addPage( new SpecialChemicalsources );
-
+ #Creates a table row
+ function GetParam_Row($p, $q, $action, $go) {
+ global $wgOut;
+ $wgOut->addHTML ( wfMsg( $p ) . ": ");
+ $wgOut->addHTML(" |
+
+ |
");
+ $wgOut->addHTML("");
+ }
}
#End of php.
|