Source for file FormatLogList.php

Documentation is available at FormatLogList.php

  1. <?php
  2. /*
  3. * This file is part of Sylar.
  4. *
  5. * Sylar is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Sylar is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with Sylar. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * @copyright Copyright Sylar Development Team
  19. * @license http://www.gnu.org/licenses/ GNU Public License V2.0
  20. * @see https://launchpad.net/sylar/
  21. * @see http://www.giano-solutions.com
  22. */
  23.  
  24. import('sylar.common.data.SimpleTable');
  25. import('app.giano.presentation.Format');
  26. /**
  27. * Example of format class
  28. * It format informations about log
  29. *
  30. * @package Sylar
  31. * @version 1.0
  32. * @since 05/mar/08
  33. *
  34. * @author Gianluca Giusti [brdp] <g.giusti@giano-solutions.com>
  35. * @copyright Sylar Development Team
  36. */
  37. class FormatLogList extends App_Format{
  38. function __construct(){
  39. parent::__construct();
  40. }
  41. function __destruct(){
  42. // nothing to do at the moment
  43. }
  44. /**
  45. * Example of format class
  46. * Format logs from Db in a txt list
  47. *
  48. * @param Sylar_SimpleTable $sTable
  49. * @return string
  50. */
  51. public function makeLogList(Sylar_SimpleTable $sTable){
  52. $result = "\n Table Title: ".$sTable->getTableTitle();
  53. $result .= "\n Table Id: ".$sTable->getTableId();
  54. $result .= "\n Table Description: ".$sTable->getTableDescription();
  55. $result .= "\n-------------------------------------------------------------\n";
  56. for($i=0; $i<$sTable->getRows(); $i++){
  57. for($j=0; $j<$sTable->getColumnsHeader()->getColumns(); $j++){
  58. $result .= "\n- ".$sTable->getColumnsHeader()->getColumnById($j)->getColumnCode().": ".$sTable->getRow($i)->getColumnValue($j);
  59. }
  60. $result .= "\n-------------------------------------------------------------";
  61. }
  62.  
  63. return $result;
  64. }
  65. /**
  66. * Example of format class
  67. * Format logs from Db in a html table list
  68. *
  69. * @param Sylar_SimpleTable $sTable
  70. * @return string
  71. */
  72. public function makeHtmlLogList(Sylar_SimpleTable $sTable){
  73. //Table start
  74. $result = "\n<table class='sample' id='".$sTable->getTableId()."' name='".$sTable->getTableTitle()."'>";
  75. // Table Caption
  76. $result .= "\n<CAPTION>Titolo: ".$sTable->getTableTitle()."</CAPTION>";
  77. // All Columns Header
  78. $result .= "\n<tr>";
  79. for($i=0; $i<$sTable->getColumnsHeader()->getColumns(); $i++){
  80. $result .= "\n<th>".$sTable->getColumnsHeader()->getColumnById($i)->getColumnCode()."</th>";
  81. }
  82. $result .= "\n</tr>";
  83. // All the rows with values
  84. for($i=0; $i<$sTable->getRows(); $i++){
  85. $result .= "\n<tr>";
  86. for($j=0; $j<$sTable->getColumns(); $j++){
  87. $result .= "\n<td>".$sTable->getRow($i)->getColumnValue($j)."</td>";
  88. }
  89. $result .= "\n</tr>";
  90. }
  91. $result .= "\n</table>";
  92. // style if you want
  93. $result .= "
  94. <style type=\"text/css\">
  95. table.sample {
  96. border-width: 2px 2px 2px 2px;
  97. border-spacing: 2px;
  98. border-style: solid solid solid solid;
  99. border-color: black black black black;
  100. border-collapse: separate;
  101. background-color: rgb(255, 250, 250);
  102. }
  103. table.sample th {
  104. border-width: 1px 1px 1px 1px;
  105. padding: 3px 3px 3px 3px;
  106. border-style: solid solid solid solid;
  107. border-color: red red red red;
  108. background-color: white;
  109. -moz-border-radius: 0px 0px 0px 0px;
  110. }
  111. table.sample td {
  112. border-width: 1px 1px 1px 1px;
  113. padding: 3px 3px 3px 3px;
  114. border-style: solid solid solid solid;
  115. border-color: red red red red;
  116. background-color: white;
  117. -moz-border-radius: 0px 0px 0px 0px;
  118. }
  119. </style>";
  120. return $result;
  121. }
  122.  
  123. }
  124. ?>

Documentation generated on Thu, 24 Apr 2008 16:14:14 +0200 by phpDocumentor 1.3.0RC3