| @@ -16,11 +16,17 @@ | ||
| 16 | 16 | :ix"; |
| 17 | 17 | } /* function FeedWordPressHTML::attributeRegex () */ |
| 18 | 18 | |
| 19 | 19 | function attributeMatch ($matches) { |
| 20 | - $suffix = (isset($matches[12]) ? $matches[12] : $matches[9]); | |
| 21 | - $value = (isset($matches[10]) ? $matches[10] : $matches[7]); | |
| 20 | + for ($i = 0; $i <= 12; $i++) : | |
| 21 | + if (!isset($matches[$i])) : | |
| 22 | + $matches[$i] = ''; | |
| 23 | + endif; | |
| 24 | + endfor; | |
| 22 | 25 | |
| 26 | + $suffix = $matches[12].$matches[9]; | |
| 27 | + $value = $matches[10].$matches[7]; | |
| 28 | + | |
| 23 | 29 | return array( |
| 24 | 30 | "tag" => $matches[3], |
| 25 | 31 | "attribute" => $matches[4], |
| 26 | 32 | "value" => $value, |
| @@ -30,6 +36,51 @@ | ||
| 30 | 36 | "before_attribute" => $matches[2], |
| 31 | 37 | "after_attribute" => $suffix, |
| 32 | 38 | ); |
| 33 | 39 | } /* function FeedWordPressHTML::attributeMatch () */ |
| 40 | + | |
| 41 | + function tagWithAttributeRegex ($tag, $attr, $value) { | |
| 42 | + return ":( | |
| 43 | + (<($tag)\s+[^>]*) | |
| 44 | + ($attr)= | |
| 45 | + ) | |
| 46 | + ( | |
| 47 | + \s*(\"|') | |
| 48 | + ((((?!\\6).)*\s)*($value)(\s((?!\\6).)*)*) | |
| 49 | + \\6([^>]*>) | |
| 50 | + | | |
| 51 | + \s*((?!/>)($value)) | |
| 52 | + ([^>]*>) | |
| 53 | + ) | |
| 54 | + (((?!</($tag)>).)*) | |
| 55 | + (</($tag)>) | |
| 56 | + :ix"; | |
| 57 | + } /* FeedWordPressHTML::tagWithAttributeRegex () */ | |
| 58 | + | |
| 59 | + function tagWithAttributeMatch ($matches) { | |
| 60 | + for ($i = 0; $i <= 21; $i++) : | |
| 61 | + if (!isset($matches[$i])) : | |
| 62 | + $matches[$i] = ''; | |
| 63 | + endif; | |
| 64 | + endfor; | |
| 65 | + | |
| 66 | + $suffix = $matches[16].$matches[13]; | |
| 67 | + $value = $matches[14].$matches[7]; | |
| 68 | + | |
| 69 | + return array( | |
| 70 | + "full" => $matches[0], | |
| 71 | + "tag" => $matches[3], | |
| 72 | + "attribute" => $matches[4], | |
| 73 | + "value" => $value, | |
| 74 | + "quote" => $matches[6], | |
| 75 | + "prefix" => $matches[1].$matches[6], | |
| 76 | + "suffix" => $matches[6].$suffix, | |
| 77 | + "before_attribute" => $matches[2], | |
| 78 | + "after_attribute" => $suffix, | |
| 79 | + "open_tag" => $matches[1].$matches[6].$value.$matches[6].$suffix, | |
| 80 | + "content" => $matches[17], | |
| 81 | + "close_tag" => $matches[20], | |
| 82 | + ); | |
| 83 | + | |
| 84 | + } /* FeedWordPressHTML::tagWithAttributeMatch () */ | |
| 34 | 85 | } /* class FeedWordPressHTML */ |
| 35 | 86 | |