MISConfig.class.inc 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. /*
  3. * DON'T REMOVE THE FOLLOWING LICENSE
  4. * INFORMATION!
  5. * ----------------------------------
  6. * Copyright by
  7. * Global Cube Business Solutions
  8. * Author: Dennis Ritz
  9. * info@global-cube.de
  10. * 2007-2008
  11. * ----------------------------------
  12. */
  13. /*
  14. * DATA Class
  15. * This class is not callable for clients
  16. */
  17. define('CONFIG_SESSION', 'MISConfig');
  18. require_once(ROOT_DIR."init.inc");
  19. class MISConfig extends App {
  20. static private $generatedSectionIDs = array();
  21. static private $generatedReportIDs = array();
  22. static private $generatedImageIDs = array();
  23. static private $generatedScorecardIDs = array();
  24. public function __construct() {
  25. parent::__construct(__file__);
  26. }
  27. public function getDefaultConfigFile() {
  28. $settingsDOM = new DOMDocument('1.0', 'iso-8859-1');
  29. $settingsDOM->load(ROOT_DIR."apps/".__CLASS__."/".__CLASS__.".settings.xml");
  30. $settingsXpath = new DOMXpath($settingsDOM);
  31. $defaultConfigFile = $settingsXpath->query("/settings/defaultConfigFile")->item(0)->nodeValue;
  32. if(!file_exists(ROOT_DIR."apps/".__CLASS__."/data/".$defaultConfigFile)) {
  33. $defaultConfigFile = $settingsXpath->query("/settings/rescueConfigFile")->item(0)->nodeValue;
  34. $this->setDefaultConfigFile($defaultConfigFile);
  35. }
  36. return $defaultConfigFile;
  37. }
  38. public function setDefaultConfigFile($p_configFile) {
  39. $settingsDOM = new DOMDocument('1.0', 'iso-8859-1');
  40. $settingsDOM->load(ROOT_DIR."apps/".__CLASS__."/".__CLASS__.".settings.xml");
  41. $settingsXpath = new DOMXpath($settingsDOM);
  42. $settingsNode = $settingsXpath->query("/settings")->item(0);
  43. $this->setNodeValue("defaultConfigFile",$p_configFile,$settingsDOM,$settingsNode);
  44. $settingsDOM->save(ROOT_DIR."apps/".__CLASS__."/".__CLASS__.".settings.xml");
  45. }
  46. public function setConfigFile($p_configFile) {
  47. $_SESSION[CONFIG_SESSION]['configFile'] = utf8_encode($p_configFile);
  48. }
  49. public function getConfigFile() {
  50. if(!empty($_SESSION[CONFIG_SESSION]) && !empty($_SESSION[CONFIG_SESSION]['configFile'])
  51. && file_exists(ROOT_DIR."apps/".__CLASS__."/data/".$_SESSION[CONFIG_SESSION]['configFile']))
  52. return ROOT_DIR."apps/".__CLASS__."/data/".$_SESSION[CONFIG_SESSION]['configFile'];
  53. else {
  54. $this->setConfigFile($this->getDefaultConfigFile());
  55. return ROOT_DIR."apps/".__CLASS__."/data/".$this->getDefaultConfigFile();
  56. }
  57. }
  58. public function getAllConfigFiles(){
  59. $dataDir = ROOT_DIR."apps/MISConfig/data/";
  60. $dataDirArr = array();
  61. $handle = opendir($dataDir);
  62. while ($file = readdir ($handle)) {
  63. if($file != "." && $file != "..") {
  64. if(is_file($dataDir.$file)) {
  65. $dataDirArr[] = $file;
  66. }
  67. }
  68. }
  69. return $dataDirArr;
  70. }
  71. public function getConfigFilesPath() {
  72. return $dataDir = ROOT_DIR."apps/".__CLASS__."/data/";
  73. }
  74. public function getTempFilesPath() {
  75. return $dataDir = ROOT_DIR."temp/";
  76. }
  77. public function setNodeValue($p_nodeName,$p_nodeValue,$p_DOM,$p_parentNode,$p_item=0) {
  78. $p_Xpath = new DOMXpath($p_DOM);
  79. $temp = $p_DOM->createElement($p_nodeName);
  80. $temp->appendChild($p_DOM->createTextNode(utf8_encode($p_nodeValue)));
  81. $nodeList = $p_Xpath->query("./".$p_nodeName,$p_parentNode);
  82. if($nodeList->length >0 && $nodeList->length > $p_item)
  83. $p_parentNode->replaceChild($temp,$p_parentNode->getElementsByTagName($p_nodeName)->item($p_item));
  84. else
  85. $p_parentNode->appendChild($temp);
  86. }
  87. public function getAllLangs(){
  88. return array("de" => "deutsch","en" => "english","fr" => "französisch","it" => "italiano");
  89. }
  90. public function getAllViews() {
  91. return array("Client" => "Client","Info-User" => "Info-User");
  92. }
  93. public function getAllPPR(){
  94. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  95. $projectDOM->load($this->getConfigFile());
  96. $projectXpath = new DOMXpath($projectDOM);
  97. $PPRPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  98. $PPRArr = array();
  99. $handle = opendir($PPRPath);
  100. while ($file = readdir ($handle)) {
  101. if($file != "." && $file != "..") {
  102. if(is_file($PPRPath."/".$file)) {
  103. //$filename = substr($file,0,strripos($file,"."));
  104. if("ppr" == getFileExtension($file)) {
  105. $filename = basename($file,".ppr");
  106. $filename = basename($filename,"_Graf");
  107. if(!in_array($filename,$PPRArr)) {
  108. array_push($PPRArr,$filename);
  109. }
  110. }
  111. }
  112. }
  113. }
  114. if(!$this->isRole("admin")) return array();
  115. return $PPRArr;
  116. }
  117. public function getAllScorcardFormats() {
  118. return array($this->_getI18N("Ganzzahlig"),$this->_getI18N("ZahlMitTrennz"),$this->_getI18N("ZahlOhneTrennz"),$this->_getI18N("Waehrung"),$this->_getI18N("Prozent"));
  119. }
  120. public function getAllPPRprimary() {
  121. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  122. $projectDOM->load($this->getConfigFile());
  123. $projectXpath = new DOMXpath($projectDOM);
  124. $PPRPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  125. $PPRArr = array();
  126. $handle = opendir($PPRPath);
  127. while ($file = readdir ($handle)) {
  128. if($file != "." && $file != "..") {
  129. if(is_file($PPRPath."/".$file)) {
  130. $filename = substr($file,0,strripos($file,"."));
  131. array_push($PPRArr,$filename);
  132. }
  133. }
  134. }
  135. return $PPRArr;
  136. }
  137. public function getAllImageTypes() {
  138. return array(
  139. $this->_getI18N("Kreuztabelle"),
  140. $this->_getI18N("Kreisdiagramm"),
  141. $this->_getI18N("ThreeD_Kreisdiagramm"),
  142. $this->_getI18N("Balkendiagramm"),
  143. $this->_getI18N("Balkengruppendiagramm"),
  144. $this->_getI18N("Stapelbalkendiagramm"),
  145. $this->_getI18N("Liniendiagramm"),
  146. $this->_getI18N("Mehrliniendiagramm"),
  147. $this->_getI18N("Korrelationsdiagramm"),
  148. $this->_getI18N("Punktdiagramm"));
  149. }
  150. public function getDataFile() {
  151. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  152. $projectDOM->load($MISConfig->getConfigFile());
  153. $projectXpath = new DOMXpath($projectDOM);
  154. $dataFile = $projectXpath->query("/Configuration/General/PublishImagePath")->item(0)->nodeValue;
  155. return $dataFile.$this->getUsername()."/data.xml";
  156. }
  157. }
  158. ?>