/** * Validate definition * * @param string $definition * @return mixed - success: boolean, unsuccess: string - message error * @author Sergey Startsev */ protected function doValidatePacked() { $definition = $this->getDefinition(); $tempPath = tempnam(sys_get_temp_dir(), 'studio_wi_wb') . '.xml'; afStudioUtil::writeFile($tempPath, $definition); $validator = new XmlValidator($tempPath); $status = $validator->validateXmlDocument(); unlink($tempPath); $status = $validator->validateXmlDocument(true); if ($status[0] == self::IDENTIFICATOR_ERROR) { $return = trim($status[1]->getMessage()); } else { $return = true; } return $return; }
public function readXmlDocument($path = null, $security = false, $uri = false) { $page = false; if (!$uri) { $action = sfContext::getInstance()->getActionName(); $module = sfContext::getInstance()->getModuleName(); } else { $module = strtok($uri, "/"); $action = strtok("/"); } if ($path === null) { $pathCU = new afConfigUtils($module); $path = $pathCU->getConfigFilePath($action . '.xml', true); if (strstr($path, "page")) { $page = true; } } $hash = sha1_file($path); $obj = afValidatorCachePeer::inCache($path); if (!$obj || $obj->getSignature() != $hash) { $doc = new XmlValidator($path, $security, false, false, $page ? $this->context->getModuleName() . "/" . $this->context->getActionName() : null); $doc->validateXmlDocument(); $this->document = $doc->getXmlDocument(); $this->validator = $doc; } else { $this->document = new DOMDocument(); $this->document->load($path); } parent::setNamespace($security); parent::setXmlDocument($this->document); parent::setXpath(); XmlBaseElementParser::clearRetVal(); }