Ejemplo n.º 1
0
 function isValidContent($sContent)
 {
     if (trim($sContent) == "" || strstr($sContent, '<translate><translate>')) {
         return false;
     }
     AnwDebug::startBench("isValidContent");
     //prepare for validation test
     try {
         AnwXml::xmlIsValid($sContentTmp);
         $bTest = true;
     } catch (AnwUnexpectedException $e) {
         $bTest = false;
     }
     if ($this->bExists) {
         try {
             $this->getPageGroup()->getContentClass()->testContent($sContent);
         } catch (AnwInvalidContentException $e) {
             $bTest = false;
         }
     }
     AnwDebug::stopBench("isValidContent");
     return $bTest;
 }
Ejemplo n.º 2
0
 function testValue($sValue)
 {
     if (!AnwXml::xmlIsValid($sValue)) {
         //XML error found
         $sXmlErrors = '<ul>';
         $aoLibXmlErrors = libxml_get_errors();
         foreach ($aoLibXmlErrors as $oLibXmlError) {
             $sMessage = $oLibXmlError->message;
             if (!strstr($sMessage, "Premature end of data")) {
                 //TODO dirty #CONTENTFIELDINPUTID#
                 $sMessage = preg_replace('! line ([0-9]*) and doc!si', ' <a class="textareafocusline" onclick="setTextareaFocusLine($1,$(\'#CONTENTFIELDINPUTID#\'))">line $1</a>', $sMessage);
                 $sXmlErrors .= '<li>' . $sMessage . '</li>';
             }
         }
         $sXmlErrors .= '</ul>';
         $sError = AnwComponent::g_editcontent("err_contentfield_xml_invalid", array("xmlerrors" => $sXmlErrors));
         throw new AnwInvalidContentFieldValueException($sError);
     } else {
         if (AnwUtils::contentHasPhpCode($sValue)) {
             if ($this->bCheckPhpSyntax) {
                 $sPhpError = null;
                 //gets modified by evalMixedPhpSyntax
                 if (AnwUtils::evalMixedPhpSyntax($sValue, $sPhpError)) {
                     //print "ok";
                 } else {
                     //better php error : hide file, and add a link to the line
                     //TODO dirty #CONTENTFIELDINPUTID#
                     $sPhpError = preg_replace('!in (.*) on line <b>([0-9]*)</b>!si', '<a class="textareafocusline" onclick="setTextareaFocusLine($2,$(\'#CONTENTFIELDINPUTID#\'))">on line $2</a>', $sPhpError);
                     $sError = $sPhpError;
                     throw new AnwInvalidContentFieldValueException($sError);
                 }
             }
         }
     }
 }