• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

content/classes/class.ilObjSCORMValidator.php

Go to the documentation of this file.
00001 <?php
00002         /*
00003                 +-----------------------------------------------------------------------------+
00004                 | ILIAS open source                                                           |
00005                 +-----------------------------------------------------------------------------+
00006                 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007                 |                                                                             |
00008                 | This program is free software; you can redistribute it and/or               |
00009                 | modify it under the terms of the GNU General Public License                 |
00010                 | as published by the Free Software Foundation; either version 2              |
00011                 | of the License, or (at your option) any later version.                      |
00012                 |                                                                             |
00013                 | This program is distributed in the hope that it will be useful,             |
00014                 | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015                 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016                 | GNU General Public License for more details.                                |
00017                 |                                                                             |
00018                 | You should have received a copy of the GNU General Public License           |
00019                 | along with this program; if not, write to the Free Software                 |
00020                 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021                 +-----------------------------------------------------------------------------+
00022         */
00023 
00024 
00033 class ilObjSCORMValidator {
00034                 var $dir,$flag,$summary;
00035 
00036                 function validateXML($file)
00037                 {
00038 //echo "<br>".ilUtil::getJavaPath()." -jar ".ILIAS_ABSOLUTE_PATH."/java/vali.jar ".$file." 2>&1";
00039                         exec(ilUtil::getJavaPath()." -jar ".ilUtil::escapeShellArg(ILIAS_ABSOLUTE_PATH."/java/vali.jar")." ".ilUtil::escapeShellArg($file)." 2>&1", $error);
00040                         if (count($error) != 0)
00041                         {
00042                                 $this->summary[] = "";
00043                                 $this->summary[] = "<b>File: $file</b>";
00044                                 foreach($error as $line)
00045                                 {
00046                                         $this->summary[] = $line;
00047 //echo "<br><b>".$line."</b>";
00048                                 }
00049                         }
00050                 }
00051 
00052                 function searchDir($dir) {
00053                         if (is_dir($dir)) {
00054                                 if ($dh = opendir($dir)) {
00055                                         while (($file = readdir($dh)) !== false) {
00056                                                 if (!eregi("^[\.]{1,2}",$file)) {
00057                                                         //2DO FIXME regex machen dass nur . und .. erkannt werden und nicht .lala. oder so
00058                                                         if (is_dir($dir.$file)) {
00059                                                                 // This is commented because subdirecories of my scromexamples contain xml files which aren't valid!
00060                                                                 //$this->searchDir($dir.$file."/");
00061                                                         }
00062                                                         if (eregi("(\.xml)$",$file)) {
00063                                                                 $this->validateXML($dir.$file);
00064                                                         }
00065                                                 }
00066                                         }
00067                                 }
00068                                 closedir($dh);
00069                         }
00070                 }
00071 
00072                 function ilObjSCORMValidator($directory) {
00073                         $this->dir = $directory.'/';
00074                 }
00075 
00076                 function validate()
00077                 {
00078                         $this->summary = array();
00079                         $this->searchDir($this->dir);
00080                         if(count($this->summary) == 0)
00081                         {
00082                                 return true;
00083                         }
00084                         else
00085                         {
00086                                 return false;
00087                         }
00088                 }
00089 
00090                 function getSummary()
00091                 {
00092                         $summary = "";
00093 
00094                         foreach ($this->summary as $line)
00095                         {
00096                                 $summary .= $line."<br>";
00097                         }
00098 
00099                         return $summary;
00100                 }
00101 }
00102 
00103 ?>

Generated on Fri Dec 13 2013 13:52:09 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1