本文整理匯總了PHP中NNFrameworkFunctions::getFormRegex方法的典型用法代碼示例。如果您正苦於以下問題:PHP NNFrameworkFunctions::getFormRegex方法的具體用法?PHP NNFrameworkFunctions::getFormRegex怎麽用?PHP NNFrameworkFunctions::getFormRegex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NNFrameworkFunctions
的用法示例。
在下文中一共展示了NNFrameworkFunctions::getFormRegex方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: protectForm
static function protectForm(&$string, $tags = array(), $protected = array())
{
if (!NNFrameworkFunctions::isEditPage()) {
return;
}
if (!is_array($tags)) {
$tags = array($tags);
}
if (empty($protected)) {
$protected = array();
foreach ($tags as $i => $tag) {
$protected[$i] = base64_encode($tag);
}
}
$string = preg_replace(NNFrameworkFunctions::getFormRegex(1), '<!-- TMP_START_EDITOR -->\\1', $string);
$string = explode('<!-- TMP_START_EDITOR -->', $string);
foreach ($string as $i => $str) {
if (!empty($str) != '' && fmod($i, 2)) {
$pass = 0;
foreach ($tags as $tag) {
if (!(strpos($str, $tag) === false)) {
$pass = 1;
break;
}
}
if ($pass) {
$str = explode('</form>', $str, 2);
// protect tags only inside form fields
if (preg_match_all('#(<textarea[^>]*>.*?<\\/textarea>|<input[^>]*>)#si', $str['0'], $matches, PREG_SET_ORDER) > 0) {
foreach ($matches as $match) {
$field = str_replace($tags, $protected, $match['0']);
$str['0'] = str_replace($match['0'], $field, $str['0']);
}
}
$string[$i] = implode('</form>', $str);
}
}
}
$string = implode('', $string);
}
示例2: protectForm
static function protectForm(&$string, $tags = array(), $protected = array())
{
if (!NNFrameworkFunctions::isEditPage()) {
return;
}
if (!is_array($tags)) {
$tags = array($tags);
}
if (empty($protected)) {
$protected = array();
foreach ($tags as $i => $tag) {
$protected[$i] = base64_encode($tag);
}
}
$string = preg_replace(NNFrameworkFunctions::getFormRegex(1), '<!-- TMP_START_EDITOR -->\\1', $string);
$string = explode('<!-- TMP_START_EDITOR -->', $string);
foreach ($string as $i => $str) {
if (!empty($str) != '' && fmod($i, 2)) {
$pass = 0;
foreach ($tags as $tag) {
if (!(strpos($str, $tag) === false)) {
$pass = 1;
break;
}
}
if ($pass) {
$str = explode('</form>', $str, 2);
$str['0'] = str_replace($tags, $protected, $str['0']);
$string[$i] = implode('</form>', $str);
}
}
}
$string = implode('', $string);
}