<commit_before><?php
header('Content-Type: text/html; charset=utf-8');

$singlespecies = new Singlespecies();



// Class that generates single species HTML

class Singlespecies {

  var $abbr = "";
  var $html = "";
  var $singleSpeciesDataArr = Array();
  var $singleSpeciesImageDataArr = Array();

  function __construct()
  {
    // Get parameters
    $this->abbr = $_GET['abbr'];

    // Security
    if (strlen($this->abbr) != 6)
    {
      exit("Virheellinen lyhenne");
    }

    // Get data
    $this->getSpeciesData();

    $this->createHTML();

//    print_r ($this->singleSpeciesDataArr); // debug

  }

  function getSpeciesData()
  {
    $allSpeciesDataArr = $this->getJsonData("speciesdata-autogenerated.json");
    $allSpeciesImageDataArr = $this->getJsonData("images/speciesimagedata-autogenerated.json");

    $this->singleSpeciesDataArr = $allSpeciesDataArr[$this->abbr];
    $this->singleSpeciesImageDataArr = $allSpeciesImageDataArr[$this->singleSpeciesDataArr['sci']];
  }

  // Gets a JSON datafile and decodes it
  function getJsonData($jsonFilename)
  {
    if (! file_exists($jsonFilename))
    {
      return FALSE;
    }

    $json = file_get_contents($jsonFilename);
    $dataArr = json_decode($json, TRUE);

    //  print_r ($dataArr); // debug

    return $dataArr;
  }

  function createHTML()
  {
    $this->html .= "<div id='singlespecies' class='modal'>\n";

    $this->html .= "<div class='largeSpeciesImage'>
      <img src='images/species/800/" . $this->singleSpeciesDataArr['sci'] . ".jpg' alt='' />
    </div>\n";

    $this->html .= "<h4>" . $this->singleSpeciesDataArr['fi'] . "</h4>\n";
    $this->html .= "<h5><em>" . $this->singleSpeciesDataArr['sci'] . "</em> | " . $this->singleSpeciesDataArr['sv'] . " | " . $this->singleSpeciesDataArr['en'] . "</h5>\n";

    if ("CR" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex cr uhanalainen'>Äärimmäisen uhanalainen</p>\n";
    }
    elseif ("EN" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex en uhanalainen'>Erittäinen uhanalainen</p>\n";
    }
    elseif ("VU" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex vu uhanalainen'>Vaarantunut</p>\n";
    }
    elseif ("NT" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex nt'>Silmälläpidettävä</p>\n";
    }    
    else
    {
      $this->html .= "<p id='uhex lc'>Ei uhanalainen</p>\n";
    }

    $this->html .= "<p id='atlas'>Lintuatlaksen mukaan:<br />";
    $this->html .= "Pesiviä pareja keskimäärin " . $this->singleSpeciesDataArr['atlas']['paritKa'] . ", eli on ";
    $this->html .= "Suomen " . $this->singleSpeciesDataArr['atlas']['paritKaJarjestys'] . ". runsaslukuisin lintulaji.<br />";
    $this->html .= "Pesii enintään " . $this->singleSpeciesDataArr['atlas']['ruudutYht'] . " ruudussa, eli on ";
    $this->html .= "Suomen " . $this->singleSpeciesDataArr['atlas']['ruudutYhtJarjestys'] . ". laajimmalle levinnyt lintulaji.<br />";
    $this->html .= "</p>";

    $this->html .= "<p id='photocredits'>Kuva: " .
        "<a href='" . $this->singleSpeciesImageDataArr['authorUrl'] . "'>" .
        $this->singleSpeciesImageDataArr['author']
        . "</a>
    </p>";

    $this->html .= "</div>\n";

    echo $this->html;
  }



} // end of class<commit_msg>Photo credit: photo name & url<commit_after><?php
header('Content-Type: text/html; charset=utf-8');

$singlespecies = new Singlespecies();



// Class that generates single species HTML

class Singlespecies {

  var $abbr = "";
  var $html = "";
  var $singleSpeciesDataArr = Array();
  var $singleSpeciesImageDataArr = Array();

  function __construct()
  {
    // Get parameters
    $this->abbr = $_GET['abbr'];

    // Security
    if (strlen($this->abbr) != 6)
    {
      exit("Virheellinen lyhenne");
    }

    // Get data
    $this->getSpeciesData();

    $this->createHTML();

//    print_r ($this->singleSpeciesDataArr); // debug

  }

  function getSpeciesData()
  {
    $allSpeciesDataArr = $this->getJsonData("speciesdata-autogenerated.json");
    $allSpeciesImageDataArr = $this->getJsonData("images/speciesimagedata-autogenerated.json");

    $this->singleSpeciesDataArr = $allSpeciesDataArr[$this->abbr];
    $this->singleSpeciesImageDataArr = $allSpeciesImageDataArr[$this->singleSpeciesDataArr['sci']];
  }

  // Gets a JSON datafile and decodes it
  function getJsonData($jsonFilename)
  {
    if (! file_exists($jsonFilename))
    {
      return FALSE;
    }

    $json = file_get_contents($jsonFilename);
    $dataArr = json_decode($json, TRUE);

    //  print_r ($dataArr); // debug

    return $dataArr;
  }

  function createHTML()
  {
    $this->html .= "<div id='singlespecies' class='modal'>\n";

    $this->html .= "<div class='largeSpeciesImage'>
      <img src='images/species/800/" . $this->singleSpeciesDataArr['sci'] . ".jpg' alt='' />
    </div>\n";

    $this->html .= "<h4>" . $this->singleSpeciesDataArr['fi'] . "</h4>\n";
    $this->html .= "<h5><em>" . $this->singleSpeciesDataArr['sci'] . "</em> | " . $this->singleSpeciesDataArr['sv'] . " | " . $this->singleSpeciesDataArr['en'] . "</h5>\n";

    if ("CR" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex cr uhanalainen'>Äärimmäisen uhanalainen</p>\n";
    }
    elseif ("EN" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex en uhanalainen'>Erittäinen uhanalainen</p>\n";
    }
    elseif ("VU" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex vu uhanalainen'>Vaarantunut</p>\n";
    }
    elseif ("NT" == $this->singleSpeciesDataArr['uhex']['luokka2015'])
    {
      $this->html .= "<p id='uhex nt'>Silmälläpidettävä</p>\n";
    }    
    else
    {
      $this->html .= "<p id='uhex lc'>Ei uhanalainen</p>\n";
    }

    $this->html .= "<p id='atlas'>Lintuatlaksen mukaan:<br />";
    $this->html .= "Pesiviä pareja keskimäärin " . $this->singleSpeciesDataArr['atlas']['paritKa'] . ", eli on ";
    $this->html .= "Suomen " . $this->singleSpeciesDataArr['atlas']['paritKaJarjestys'] . ". runsaslukuisin lintulaji.<br />";
    $this->html .= "Pesii enintään " . $this->singleSpeciesDataArr['atlas']['ruudutYht'] . " ruudussa, eli on ";
    $this->html .= "Suomen " . $this->singleSpeciesDataArr['atlas']['ruudutYhtJarjestys'] . ". laajimmalle levinnyt lintulaji.<br />";
    $this->html .= "</p>";

    $this->html .= "<p id='photocredits'>Kuva: " .
        "<a href='" . $this->singleSpeciesImageDataArr['authorUrl'] . "'>" . 
        $this->singleSpeciesImageDataArr['author'] .
        "</a>, " .
        "<a href='" . $this->singleSpeciesImageDataArr['url'] . "'>" .
        $this->singleSpeciesImageDataArr['name'] .
        "</a>

    </p>";

    $this->html .= "</div>\n";

    echo $this->html;
  }



} // end of class
{'fraction_non_alphanumeric': 0.20690647482014388, 'fraction_numerical': 0.007194244604316547, 'mean_word_length': 3.2435897435897436, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 155, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2924324', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2502, 'n_words': 386}