Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
test_tidy_errors.inc
1 <?php
28 {
29 
30 
37  public static function getName()
38  {
39  return 'HTML Tidy Errors Test';
40 
41  }//end getName()
42 
43 
50  public static function getDescription()
51  {
52  return 'A test to find HTML Tidy fails in WYSIWYG content areas';
53 
54  }//end getDescription()
55 
56 
66  public static function test(&$messages, &$errors)
67  {
68  $status = TRUE;
69  $count = 0;
70  $am = $GLOBALS['SQ_SYSTEM']->am;
71  $wysiwygs = $am->getTypeAssetids('content_type_wysiwyg');
72 
73  foreach ($wysiwygs as $wysiwyg) {
74  $asset = $am->getAsset($wysiwyg, '', TRUE);
75  if (is_null($asset)) {
76  $status = FALSE;
77  $count++;
78  $errors[] = 'Asset #'.$wysiwyg.' could not be loaded';
79  } else {
80  $tidyStatus = $asset->attr('htmltidy_status');
81  if ($tidyStatus != 'pass') {
82  $status = FALSE;
83  $count++;
84  $errors[] = 'HTML Tidy has not validated Asset #'.$wysiwyg;
85  }//end if
86  $am->forgetAsset($asset, TRUE);
87  }//end if
88  }//end foreach
89 
90  if (!$status && !empty($count)) {
91  $messages[] = 'There are '.$count.' content types with HTML Tidy issues';
92  }//end if
93 
94  return $status;
95 
96  }//end test()
97 
98 }//end class
99 ?>