39 return 'Invalid Matrix Links Test';
52 return 'A test to check for invalid Matrix links in content areas';
66 public static function test(&$messages, &$errors)
69 $am = $GLOBALS[
'SQ_SYSTEM']->am;
70 $content_types = $am->getTypeAssetids(
'content_type', FALSE);
71 $pattern =
'/\\.\\/\\?a=([0-9]+)/';
74 foreach ($content_types as $content_type) {
75 $error_in_content_type = FALSE;
76 $asset = $am->getAsset($content_type,
'', TRUE);
77 if (is_null($asset)) {
80 $errors[] =
'Content Type #'.$content_type.
' could not be loaded';
83 $html = $asset->attr(
'html');
84 preg_match_all($pattern, $html, $assetids);
85 foreach ($assetids[1] as $assetid) {
86 $link_asset = $am->getAsset($assetid,
'', TRUE);
87 if (is_null($link_asset)) {
89 if (!$error_in_content_type) $count++;
90 $error_in_content_type = TRUE;
91 $errors[] =
'A link to Asset #'.$assetid.
' was found on Content Type #'.$content_type;
93 $am->forgetAsset($link_asset, TRUE);
96 $am->forgetAsset($asset, TRUE);
99 $errors = array_unique($errors);
100 if (!$status && !empty($count)) {
101 $messages[] =
'There are '.$count.
' content types with problems found';