示例#1
0
 /**
  * Validates a template file.
  * You can pass either a file name, or the file content. One of the parameters
  *  needs to be !== null.
  *
  * @param string $strFile    Template file name to check
  * @param string $strContent Template content to check
  *
  * @return mixed Boolean true if no errors have been found, array of
  *                errors otherwise. An error is an array with keys
  *                - 'short' (short error code, string)
  *                - 'message' (readable message)
  *                - 'line'    (line number)
  *                - 'code'    (code that caused the error)
  *                false if no file and content is given
  */
 public static function validate($strFile = null, $strContent = null)
 {
     $arLines = HTML_Template_PHPLIB_Helper::getLines($strFile, $strContent);
     if ($arLines === false) {
         return false;
     }
     $arErrors = HTML_Template_PHPLIB_Validator::checkBlockDefinitions($arLines);
     $arErrors = array_merge($arErrors, HTML_Template_PHPLIB_Validator::checkVariables($arLines));
     HTML_Template_PHPLIB_Validator::sortByLine($arErrors);
     return count($arErrors) == 0 ? true : $arErrors;
 }