/** * Use this function to customize your own javascript rule. * $this->regex must be null if you want to customize here. * * @access public * @param JXMLElement $fieldNode The JXMLElement object representing the <field /> tag for the form field object. * * @return string A JSON string representing the javascript rules validation. */ public function getJsonRule($fieldNode) { /* TODO : Fill the associative array below, or create a JSON string manually * Note : $this->regex must be null */ $values = array(); $json = RtiprintHelperHtmlValidator::jsonFromArray($values); return "{" . LN . $json . LN . "}"; }
/** * Use this function to customize your own javascript rule. * $this->regex must be null if you want to customize here. * * @access public * @param JXMLElement $fieldNode The JXMLElement object representing the <field /> tag for the form field object. * * @return string A JSON string representing the javascript rules validation. */ public function getJsonRule($fieldNode) { $regex = ''; $allowedExtensionsText = '*.*'; if (isset($fieldNode['allowedExtensions'])) { $allowedExtensions = $fieldNode['allowedExtensions']; $allowedExtensionsText = preg_replace("/\\|/", "<br/>", $allowedExtensions); //Remove eventual '*.' $allowedExtensions = preg_replace("/\\*\\./", "", $allowedExtensions); $regex = '\\.(' . $allowedExtensions . ')$'; } $values = array("#regex" => 'new RegExp("' . $regex . '", \'i\')'); if (isset($fieldNode['msg-incorrect'])) { $values["alertText"] = LI_PREFIX . JText::_($fieldNode['msg-incorrect']); } else { $values["alertText"] = LI_PREFIX . JText::sprintf('RTIPRINT_ERROR_ALLOWED_FILES', $allowedExtensionsText); } $json = RtiprintHelperHtmlValidator::jsonFromArray($values); return "{" . LN . $json . LN . "}"; }