Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class KeywordValidator extends Validator {
- public function php($data) {
- $keywords = preg_replace('/^[^_A-z- ]+$/', '', $data['Keywords']);
- $tags = explode(' ', $keywords);
- $fail = false;
- if (count($tags) < 3) {
- $fail = true;
- }
- if (!$fail) {
- foreach ($tags as $tag) {
- if (strlen($tag) === 0) {
- $fail = true;
- }
- }
- }
- if ($fail) {
- $this->validationError('Keywords', 'There must be at least 3 valid keywords');
- return false;
- }
- return true;
- }
- public function javascript() {
- //echo "alert('somethingspecial');";
- return false;
- }
- }
- class MyPage extends Page {
- public function getCMSValidator() {
- $validator = new KeywordValidator();
- return $validator;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement