$background = (isset($style['background-color']))
? $style['background-color']
: $style['background'];
- if(!$background || $this->options['css_only_use_default']) {
+ if(!$background || (isset($this->options['css_only_use_default']) && $this->options['css_only_use_default'])) {
$background = $this->default_background;
}
$luminosity = $this->getLuminosity(
}
if($k) {
foreach($this->suspect_styles as $style) {
- if($styles[$k][$style] != $styles[($k - 1)][$style]) {
+ if(isset($styles[$k][$style]) && $styles[$k][$style] != $styles[($k - 1)][$style]) {
$form = $this->getElementAncestor($label, 'form');
if($form) {
$this->addReport($form);
*/
function check() {
foreach($this->getAllElements('p') as $p) {
- if(($p->nodeValue == $p->firstChild->nodeValue) &&
- is_object($p->firstChild) &&
+ if (is_object($p->firstChild) &&
+ ($p->nodeValue == $p->firstChild->nodeValue) &&
property_exists($p->firstChild, 'tagName') &&
in_array($p->firstChild->tagName, $this->head_tags)) {
$this->addReport($p);
}
else {
$style = $this->css->getStyle($p);
- if($style['font-weight'] == 'bold') {
+ if(isset($style['font-weight']) && $style['font-weight'] == 'bold') {
$this->addReport($p);
}
}
}
}
}
+ else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+ foreach ($child->childNodes as $tbody_child){
+ if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+ foreach($tbody_child->childNodes as $td) {
+ if($this->propertyIsEqual($td, 'tagName', 'th')) {
+ if(strlen($td->getAttribute('abbr')) > 20)
+ $this->addReport($td);
+ }
+ }
+ }
+ }
+ }
}
}
$this->addReport($table);
$first_row = false;
}
+ else if($this->propertyIsEqual($child, 'tagName', 'tbody') && $first_row) {
+ foreach($child->childNodes as $tbody_child) {
+ if($this->propertyIsEqual($tbody_child, 'tagName', 'tr') && $first_row) {
+ if(!$this->elementHasChild($tbody_child, 'th'))
+ $this->addReport($table);
+ $first_row = false;
+ }
+ }
+ }
}
}
}
}
else {
foreach($child->childNodes as $td) {
+ if (!property_exists($td, 'tagName')) continue;
if($td->tagName == 'th' && !$td->hasAttribute('scope'))
$fail = true;
}
}
}
+ else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+ foreach($child->childNodes as $tbody_child) {
+ if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+ if($this->propertyIsEqual($tbody_child->firstChild, 'tagName', 'td')) {
+ if(!$tbody_child->firstChild->hasAttribute('scope'))
+ $fail = true;
+ }
+ foreach($tbody_child->childNodes as $td) {
+ if(property_exists($td, 'tagName')){
+ if($td->tagName == 'th' && !$td->hasAttribute('scope'))
+ $fail = true;
+ }
+ }
+ }
+ }
+ }
}
if($fail)
$this->addReport($table);
if($row > 1)
$multi_headers = true;
}
-
+ }
+ }
+ else if($this->propertyIsEqual($child, 'tagName', 'tbody')) {
+ foreach($child->childNodes as $tbody_child) {
+ if($this->propertyIsEqual($tbody_child, 'tagName', 'tr')) {
+ $row ++;
+ foreach($tbody_child->childNodes as $cell) {
+ if($this->propertyIsEqual($cell, 'tagName', 'th')) {
+ $th[] = $cell;
+ if($row > 1)
+ $multi_headers = true;
+ }
+ }
+ }
}
}
}
}
-/*@}*/
\ No newline at end of file
+/*@}*/
foreach($this->css as $selector => $style) {
$xpath = new DOMXPath($this->dom);
$entries = @$xpath->query($this->getXpath($selector));
- if($entries->length) {
+ if(is_object($entries) && property_exists($entries, 'length') && $entries->length) {
foreach($entries as $e) {
if(!$e->hasAttribute('quail_style_index')) {
$e->setAttribute('quail_style_index', $this->next_index);
*/
private function addCSSToElement($element, $style, $specificity) {
$index_id = $element->getAttribute('quail_style_index');
+ if (!isset($this->style_index[$index_id])){
+ $this->style_index[$index_id] = array();
+ }
+
foreach($style as $name => $value) {
- if(!$this->style_index[$index_id][$name] ||
- $this->style_index[$index_id][$name]['specificity'] < $specificity
- || strpos($value, '!important') !== false)
+ if(!isset($this->style_index[$index_id][$name]) ||
+ !$this->style_index[$index_id][$name] ||
+ (isset($this->style_index[$index_id][$name]['specificity']) &&
+ $this->style_index[$index_id][$name]['specificity'] < $specificity) ||
+ strpos($value, '!important') !== false)
{
$this->style_index[$index_id][$name] = array(
'value' => str_replace('!important', '', trim(strtolower($value))),
$inline_styles = explode(';', $element->getAttribute('style'));
foreach($inline_styles as $inline_style) {
$s = explode(':', $inline_style);
+ if (!isset($s[1])) continue;
$style[$s[0]] = trim(strtolower($s[1]));
}
}
if($table->tagName != 'table')
return false;
foreach($table->childNodes as $child) {
- if(property_exists($child, 'tagName') && $child->tagName == 'tr') {
- foreach($child->childNodes as $row_child) {
- if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
- return true;
+ if(property_exists($child, 'tagName')){
+ if ($child->tagName == 'tr') {
+ foreach($child->childNodes as $row_child) {
+ if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
+ return true;
+ }
+ }
+ else if ($child->tagName == 'tbody') {
+ foreach($child->childNodes as $tbody_child) {
+ if (property_exists($tbody_child, 'tagName') && $tbody_child->tagName == 'tr') {
+ foreach($tbody_child->childNodes as $row_child) {
+ if(property_exists($row_child, 'tagName') && $row_child->tagName == 'th')
+ return true;
+ }
+ }
+ }
}
}
if(property_exists($child, 'tagName') && $child->tagName == 'thead')
if( $this->getLuminosity($body->getAttribute($this->foreground), $body->getAttribute($this->background)) < 5)
$this->addReport(null, null, false);
}
-}
\ No newline at end of file
+}
"imgHasAlt","Image elements must have an ""alt"" attribute","<p>All <code>img</code> elements must have an alt attribute</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
"imgAltIsDifferent","Image ""alt"" attributes should not be the same as the filename","<p>All <code>img</code> elements should have an ""alt"" attribute that is not just the name of the file, unless the filename communicates everything about the file.</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt=""dog.jpg""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
-"imgAltIsTooLong","Image Alt text is short","<p>All ""alt"" attributes for <code>img</code> elements should be clear and concise. ""Alt"" attributes over 100 characters long should be reviewed to see if they are too long.</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt=""A photograph of my very, very, very special dog whom I love so much. He is a very good dog, a loving dog, and my constant companion these many years. Yes, all agree, my dog is a good dog.""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
+"imgAltIsTooLong","Image Alt text is too long","<p>All ""alt"" attributes for <code>img</code> elements should be clear and concise. ""Alt"" attributes over 100 characters long should be reviewed to see if they are too long.</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt=""A photograph of my very, very, very special dog whom I love so much. He is a very good dog, a loving dog, and my constant companion these many years. Yes, all agree, my dog is a good dog.""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
"imgNonDecorativeHasAlt","Any non-decorative images should have a non-empty ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an empty ""alt"" attribute.</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt=""""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","2"
"imgImportantNoSpacerAlt","Images that are important should not have a purely white-space ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an ""alt"" attribute that consists solely of white space (i.e. a space, or a new line).</p><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt="" ""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
"imgAltNotPlaceHolder","Images should not have a simple placeholder text as an ""alt"" attribute","<p>Any image that is not used decorativey or which is purely for layout purposes cannot have an ""alt"" attribute that consists solely of placeholders. Placeholders include:</p><ul><li>nbsp</li><li>&nbsp;</li><li>spacer</li><li>image</li><li>img</li><li>photo</li></ul><h4>Example</h4><h5>Wrong</h5><p><code><img src=""dog.jpg"" alt=""image""></code></p><h5>Right</h5><p><code><img src=""dog.jpg"" alt=""A photograph of a dog""></code></p>","1"
"frameTitlesDescribeFunction","All ""frame"" elemetns should have a ""title"" attribute that describes the purpose of the frame","<p>Each <code>frame</code> elements should have a ""title"" attribute which describes the purpose or function of the frame.</p><h4>Example</h4><h5>Wrong</h5><p><code><frame src=""navigation.html""></frame></code></p><h5>Right</h5><p><code><frame src=""navigation.html"" title=""The site navigation""></frame></code></p>","3"
"frameSrcIsAccessible","The source for each frame is accessible content.","<p>Each frame should contain accessible content, and contain content accessible to screen readers, like HTML as opposed to an image.</p>","3"
"frameRelationshipsMustBeDescribed","Complex framesets should contain a ""longdesc"" attribute","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code><frameset cols=""25%,50%,25%""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /></frameset></code></p><h5>Right</h5><p><code><frameset cols=""25%,50%,25%"" longdesc=""description.html""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /></frameset></code></p>","2"
-"framesetMustHaveNoFramesSection","All framesets should contain a noframes section","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code><frameset cols=""25%,50%,25%""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /></frameset></code></p><h5>Right</h5><p><code><frameset cols=""25%,50%,25%"" longdesc=""description.html""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /> <noframes> <body> This is more information for users without frames. It should contain links to all the other frames. </body> </noframes></frameset></code></p>","1"
+"framesetMustHaveNoFramesSection","All framesets should contain a noframes section","<p>If a <code>frameset</code> contains three or more frames, use a ""longdesc"" attribute to help describe the purpose of the frames.</p><h4>Example</h4><h5>Wrong</h5><p><code><frameset cols=""25%,50%,25%""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /></frameset></code></p><h5>Right</h5><p><code><frameset cols=""25%,50%,25%"" longdesc=""description.html""> <frame src=""frame_1.htm"" /> <frame src=""frame_2.htm"" /> <frame src=""frame_3.htm"" /> <noframes> <body> This is more information for users without frames. It should contain links to all the other frames. </body> </noframes></frameset></code></p>","1"
"noframesSectionMustHaveTextEquivalent","All ""noframes"" elements should contain the text content from all frames","<p>The <code>noframes</code> content should either replicate or link to the content visible within the frames.</p>","2"
"headerH1","The header following an h1 is h1 or h2","<p>The header following an <code>h1</code> element should either be an <code>h2</code> or another <code>h1</code>.</p><p>Users of screen readers often use headers to make sense of the structure of the document, and having headers in the right order can be very helpful. It also helps the document itself to be consistently structured.</p>
","3"
","2"
"linkUsedToDescribeNavigation","Document uses link element to describe navigation if it is within a collection.","The link element can provide metadata about the position of an HTML page within a set of Web units or can assist in locating content with a set of Web units.","1"
"linkUsedForAlternateContent","Use a ""link"" element for alternate content","<p>Documents which contain things like videos, sound, or other forms of media that are not accessible, should provide a <code>link</code> element with a ""rel"" attribute of ""alternate"" in the document header.</p><h4>Example</h4><p><code><head><link rel=""alternate"" href=""transcription.html""/></head></code></p>","3"
-"tableUsesCaption","Data tables should contain a ""caption"" element if not described elsewhere","<p>Unless otherwise described in the document, tables should contain <code>caption</code> elements to describe the purpose of the table.</p><h4>Example</h4><table><caption>A short description of this table</caption></table>","1"
+"tableUsesCaption","Data tables should contain a ""caption"" element if not described elsewhere","<p>Unless otherwise described in the document, tables should contain <code>caption</code> elements to describe the purpose of the table.</p><h4>Example</h4><p><code><table><caption>A short description of this table</caption></table></code></p>","1"
"tableUsesAbbreviationForHeader","Table headers over 20 characters should provide an ""abbr"" attribute","<p>For long table headers, use an ""abbr"" attribute that is less than short (less than 20 characters long).</p><h4>Examples</h4><h5>Wrong</h5><p><code><th>The total number of people who liked chocolate</th></code></p><h5>Right</h5><p><code><th abbr=""Like Chocolate"">The total number of people who liked chocolate</th></code></p>","3"
"tableHeaderLabelMustBeTerse","Table header lables must be terse","<p>The ""abbr"" attribute for table headers must be terse (less than 20 characters long).</p>","2"
"preShouldNotBeUsedForTabularLayout","""Pre"" elements should not be used for tabular data","<p>If a <code>pre</code> element is used for tabular data, change the data to use a well-formed table.</p>
"labelsAreAssignedToAnInput","All labels should be associated with an input","<p>All <code>label</code> elements should be assigned to an input item, and should have a <em>for</em> attribute which equals the <em>id</em> attribute of a form element.</p>","1"
"imgAltTextNotRedundant","Unless the image files are the same, no image should contain redundant alt text","<p>Every distinct image on a page should have it's own <em>alt</em> text which is different than all the others on the page to avoid redundancy and confusion.</p><h4>Example</h4><h5>Wrong</h5><p><code><img src="rex.jpg" alt="this is an image of rex"><img src="me.jpg" alt="this is an image of rex"></code></p><h5>Right</h5><p><code><img src="rex.jpg" alt="this is an image of rex"><img src="me.jpg" alt="a photo of myself"></code></p>","1"
"selectJumpMenus","Select jump menus should jump on button press, not on state change","<p>If you wish to use a 'Jump' menu with a select item that then redirects users to another page, the jump should occur on the user pressing a button, rather than on the change event of that select eleemnt.</p>","2"
-"textIsNotSmall","The text size is not less than 9 pixels high","<p>To help users with difficulty reading small text, ensure text size is no less than 9 pixels high.</p>","2"
\ No newline at end of file
+"textIsNotSmall","The text size is not less than 9 pixels high","<p>To help users with difficulty reading small text, ensure text size is no less than 9 pixels high.</p>","2"