PageRenderTime 58ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/php/view/multilistaview.php

https://github.com/kaartine/Rysty
PHP | 144 lines | 64 code | 27 blank | 53 comment | 10 complexity | b8ae517e141f1833b703ba59e1cb9fcf MD5 | raw file
  1. <?php
  2. /**
  3. * peliview.php
  4. * Copyright Rysty 2004:
  5. * Teemu Lahtela
  6. * Jukka Kaartinen
  7. * Teemu Siitarinen
  8. *
  9. * author: Jukka
  10. * created: 20.03.2005
  11. *
  12. */
  13. require_once "view.php";
  14. /**
  15. * class MultiListaView
  16. *
  17. */
  18. class MultiListaView extends View
  19. {
  20. function MultiListaView (&$arg) {
  21. $this->View($arg);
  22. /**
  23. * 'pelaajat' => array(
  24. 'pelinumero'=>$this->tm->getText('#'),
  25. 'etunimi'=>$this->tm->getText('Etunimi'),
  26. 'sukunimi'=>$this->tm->getText('Sukunimi'),
  27. 'pelipaikka'=>$this->tm->getText('Pelipaikka'),
  28. 'kapteeni'=>$this->tm->getText('Kapteeni')),
  29. 'toimihenkilot' => array(
  30. 'etunimi'=>$this->tm->getText('Etunimi'),
  31. 'sukunimi'=>$this->tm->getText('Sukunimi'),
  32. 'tehtava'=>$this->tm->getText('Teht&auml;v&auml;'))
  33. */
  34. $this->headers = array();
  35. $this->toiminnonNimi = "";
  36. }
  37. /**
  38. * Override
  39. */
  40. function drawMiddle () {
  41. /*
  42. $this->drawList($this->toiminto->getData('pelaajat'),'pelaajat');
  43. $this->drawList($this->toiminto->getData('toimihenkilot'),'toimihenkilot');
  44. */
  45. /*print "<pre>";
  46. print_r($data);
  47. print_r($this->toiminto->links);
  48. print "</pre>";
  49. */
  50. }
  51. function drawList($data, $list) {
  52. if( count($data) == 0) {
  53. return;
  54. }
  55. $header = &$this->headers[$list];
  56. print ' <table> <tr>';
  57. foreach ($header as $key=>$label){
  58. $dir = 'asc';
  59. if ( $this->toiminto->order[$list] === $key ) {
  60. $dir = $this->toiminto->nextdirection[$list];
  61. }
  62. if( $this->toiminto->sorting == true ) {
  63. print '<th><a href="index.php?toiminto='.$this->toiminnonNimi.'&amp;sort'.$list.'='.$key.
  64. '&amp;dir='.$dir.'">'.$label.'</a></th>';
  65. }
  66. else {
  67. print '<th>'.$label.'</th>';
  68. }
  69. }
  70. print '</tr>';
  71. $i=0;
  72. foreach ($data as $rivi ) {
  73. print "<tr>";
  74. foreach ($header as $key=>$label){
  75. print "<td>";
  76. /*if( isset($this->toiminto->links[$list][$key]) ) {
  77. $this->printLink($rivi[$key], $key, $data[$i],$list);
  78. }*/
  79. // monta osaa datassa
  80. if( isset($this->toiminto->links[$list][$key][2]) and is_array($this->toiminto->links[$list][$key][0]) ) {
  81. $this->printLink($this->tm->getText($key), $key, $data[$i], $list);
  82. }
  83. else if( isset($this->toiminto->links[$list][$key]) and is_array($this->toiminto->links[$list][$key][0]) ) {
  84. $this->printLink($rivi[$key], $key, $data[$i],$list);
  85. }
  86. else {
  87. print $rivi[$key];
  88. }
  89. print "</td>";
  90. }
  91. print "</tr>";
  92. $i++;
  93. }
  94. print "</table>";
  95. }
  96. function printLink($string,$key, $data, $list) {
  97. $values = "";
  98. foreach( $this->toiminto->links[$list][$key][0] as $i) {
  99. $name = $i;
  100. $value = strtolower($data[strtolower($name)]);
  101. $values .= "&amp;".$name."=".$value;
  102. }
  103. print "<a href=\"?alitoiminto=".$this->toiminto->links[$list][$key][1].
  104. $values."\">".$string."</a>";
  105. }
  106. /*function printLink($string, $key, $value, $list) {
  107. $name = $this->toiminto->links[$list][$key][0];
  108. print "<a href=\"?alitoiminto=".$this->toiminto->links[$list][$key][1].
  109. "&amp;".$name[0]."=".$value[strtolower($name[0])]."\">".$string."</a>";
  110. }*/
  111. /** Aggregations: */
  112. /** Compositions: */
  113. /*** Attributes: ***/
  114. } // end of PeliView
  115. ?>