示例#1
0
/**
 * Validates the specified MODS XML file against the schema and logs
 * the result.
 *
 * @param string $path_to_schema
 *   The path to the MODS schema file.
 *
 * @param string $path_to_mods
 *   The path to the MODS file to be validated.
 *
 * @param object $log
 *   The Monolog logger object.
 */
function validate_mods($path_to_schema, $path_to_mods, $log)
{
    $mods = new DOMDocument();
    $mods->load($path_to_mods);
    if ($mods->schemaValidate($path_to_schema)) {
        $log->addInfo("MODS file validates", array('MODS file' => $path_to_mods));
    } else {
        $log->addWarning("MODS file does not validate", array('MODS file' => $path_to_mods));
    }
}
 /**
  * Print message to console
  *
  * @param string $msg message to print
  * @param int $error_code if greater 0, script exit with $error_code as return value
  * @param string $msg_type info, warning or error (warning and error will be printed with quit mode)
  *
  * @return int
  */
 public function msg($msg, $error_code = 0, $type = 'info')
 {
     if (is_array($msg)) {
         $msg = print_r($msg, true);
     }
     if (!isset($this->paras->options['quit']) && !$this->paras->options['quit'] || $type != 'info') {
         echo $msg . "\n";
     }
     if ($this->conf['write_to_log']) {
         $this->log->addInfo($msg);
     }
     if ($error_code !== 0) {
         exit($error_code);
     }
 }