/** * public * main process of creating file * @param * $title: validated content title (fount in <title> tag); if empty title will not be displayed * $uri: validated content URL (only in case of url input); if empty URL will not be displayed * $problem: problem type on which to create report (can be: known, likely, potential, html, css or all) * $mode: 'guideline' or 'line'; pdf document may have different layout (for known, likely, potential) depending on this var * $_gids: array of guidelines that were used as testing criteria */ public function getPDF($title, $uri, $problem, $mode, $_gids) { // set filename $date = AC_date('%Y-%m-%d'); $time = AC_date('%H-%i-%s'); $filename = 'achecker_' . $date . '_' . $time . $rand_str; $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_gids); // get list of guidelines separated by ',' if (is_array($guideline_rows)) { foreach ($guideline_rows as $id => $row) { $guidelines_text .= $row["title"] . ', '; } } $guidelines_text = substr($guidelines_text, 0, -2); // remove ending space and , // print time, date, [resource title,] [resource url,] str with guidelines $this->printInfo($title, $uri, $guidelines_text, $time); // if report by guideline if ($mode == 'guideline') { if ($problem == 'all') { $this->printGuideline('known'); $this->AddPage(); $this->printGuideline('likely'); $this->AddPage(); $this->printGuideline('potential'); if ($this->error_nr_html != -1) { $this->AddPage(); $this->printHTML(); } if ($this->error_nr_css != -1) { $this->AddPage(); $this->printCSS(); } } else { if ($problem == 'html') { $this->printHTML(); } else { if ($problem == 'css') { $this->printCSS(); } else { $this->printGuideline($problem); } } } } else { if ($mode == 'line') { if ($problem == 'all') { $this->printLine('known'); $this->AddPage(); $this->printLine('likely'); $this->AddPage(); $this->printLine('potential'); if ($this->error_nr_html != -1) { $this->AddPage(); $this->printHTML(); } if ($this->error_nr_css != -1) { $this->AddPage(); $this->printCSS(); } } else { if ($problem == 'html') { $this->printHTML(); } else { if ($problem == 'css') { $this->printCSS(); } else { $this->printLine($problem); } } } } } // close and save PDF document $path = AC_EXPORT_RPT_DIR . $filename . '.pdf'; $this->Output($path, 'F'); return $path; }
/* Inclusive Design Institute */ /* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id: index.php 495 2011-02-10 21:27:00Z cindy $ // Called by ajax request from guidelineline view report -> "make decision(s)" buttons // @ see checker/js/checker.js define('AC_INCLUDE_PATH', '../include/'); include AC_INCLUDE_PATH . 'vitals.inc.php'; include_once AC_INCLUDE_PATH . 'classes/Utility.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/UserLinksDAO.class.php'; // main process to save decisions $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_POST['gids']); if (!is_array($guideline_rows)) { echo _AC("AC_ERROR_EMPTY_GID"); exit; } $utility = new Utility(); $seals = $utility->getSeals($guideline_rows); if (is_array($seals)) { $userLinksDAO = new UserLinksDAO(); $rows = $userLinksDAO->getByUserIDAndURIAndSession($_SESSION['user_id'], $_POST['uri'], $_POST['jsessionid']); $savant->assign('user_link_id', $rows[0]['user_link_id']); $savant->assign('seals', $seals); $savant->display('checker/seals.tmpl.php'); } exit;
/** * get guideline string used to replace $html_main.{GUIDELINE} */ private function getGuidelineStr($_gids, $problem) { $guidelineStr = ''; if ($problem == 'html' || $problem == 'css') { // do not show if validation data only required return $guidelineStr; } else { $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_gids); if (is_array($guideline_rows)) { foreach ($guideline_rows as $id => $row) { $guidelineStr .= '<strong>Guides: </strong>' . str_replace(array('{TITLE}', '{HREF}'), array($row['title'] . _AC('link_open_in_new'), AC_BASE_HREF . 'guideline/view_guideline.php?id=' . $row['guideline_id']), $this->html_a) . " "; } } return $guidelineStr; } }
/** * set guideline string used to replace $html_main.{GUIDELINE} * @access private * @param none * @return set $guidelineStr * @author Cindy Qi Li */ private function setGuidelineStr() { if (!is_array($this->guidelineIDs)) { return ''; } $guidelinesDAO = new GuidelinesDAO(); $rows = $guidelinesDAO->getGuidelineByIDs($this->guidelineIDs); unset($this->guidelineStr); if (is_array($rows)) { foreach ($rows as $id => $row) { $this->guidelineStr .= str_replace(array('{TITLE}', '{HREF}'), array($row['title'] . _AC('link_open_in_new'), AC_BASE_HREF . 'guideline/view_guideline.php?id=' . $row['guideline_id']), $this->html_a) . " "; } } }
<?php /************************************************************************/ /* AChecker */ /************************************************************************/ /* Copyright (c) 2008 - 2011 */ /* Inclusive Design Institute */ /* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id$ define('AC_INCLUDE_PATH', '../include/'); include AC_INCLUDE_PATH . 'vitals.inc.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; $gid = intval($_GET["id"]); $guidelinesDAO = new GuidelinesDAO(); $rows = $guidelinesDAO->getGuidelineByIDs($gid); if (!$rows) { global $msg; $msg->addError('GUIDELINE_NOT_FOUND'); header('Location: index.php'); } else { $savant->assign('row', $rows[0]); $savant->assign('gid', $gid); $savant->display('guideline/view_guideline.tmpl.php'); }
$num_of_html_errors = $htmlValidator->getNumOfValidateError(); $savant->assign('htmlValidator', $htmlValidator); $savant->assign('num_of_html_errors', $num_of_html_errors); } // CSS Validator if (isset($cssValidator)) { $num_of_css_errors = $cssValidator->getNumOfValidateError(); $savant->assign('cssValidator', $cssValidator); $savant->assign('num_of_css_errors', $num_of_css_errors); } if (isset($aValidator)) { global $_gids; // array of the guideline_ids that have been validated against. initialized in checker/index.php // find out selected guidelines $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_gids); $guidelines_text = ""; if (is_array($guideline_rows)) { foreach ($guideline_rows as $id => $row) { $guidelines_text .= '<a title="' . $row["title"] . _AC('link_open_in_new') . '" target="_new" href="' . AC_BASE_HREF . 'guideline/view_guideline.php?id=' . $row["guideline_id"] . '">' . $row["title"] . '</a>, '; } } $guidelines_text = substr($guidelines_text, 0, -2); // remove ending space and , $num_of_total_a_errors = $aValidator->getNumOfValidateError(); $errors = $aValidator->getValidationErrorRpt(); // if it's a LOGIN user validates URI, save into database for user to make decision. // Note that results of validating uploaded files are not saved $user_link_id = ''; $allow_set_decision = 'false'; // set default allowSetDecision to 'false'
/** * private * writes AChecker info, date, time [, url] [, title] and guidelines * returns them as CSV string * @param * $input_content_type: 'file', 'paste' or http://file_path * $title: validated content title (fount in <title> tag); if empty title will not be displayed * $_gids: array of guidelines that were used as testing criteria * $date: date when function to create file called (showed in file title and inside document) * $time: time when function to create file called (showed in file title and inside document) */ private function getInfo($input_content_type, $title, $_gids, $date, $time) { // achecker info $file_content = _AC('file_title') . DELIM . 'version ' . VERSION . DELIM . $this->prepareStr(_AC('file_description')) . EOL . $this->achecker_file_url . EOL . EOL; // date, time $file_content .= str_replace("-", ".", $date) . ' ' . str_replace("-", ":", $time) . EOL; // test info if ($input_content_type != 'file' && $input_content_type != 'paste') { $file_content .= _AC('file_source_url') . DELIM . $input_content_type . EOL; } else { $file_content .= EOL; } if ($title != '') { $file_content .= _AC('file_source_title') . DELIM . $title . EOL; } else { $file_content .= EOL; } // guidelines $file_content .= EOL; $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_gids); if (is_array($guideline_rows)) { foreach ($guideline_rows as $id => $row) { $file_content .= $row["abbr"] . DELIM . _AC($row["long_name"]) . EOL; } } return $file_content; }
/** * private * prints Assertor, Test Subject, Test Criterion Sections * @param * $input_content_type: 'file', 'paste' or http://file_path * $title: validated content title (fount in <title> tag); if empty title will not be displayed * $_gids: array of guidelines that were used as testing criteria * $date: date when function to create file called (showed in file title and inside document) * returns these sections as string */ private function getAssertorTestSubjectTestCriterionSections($input_content_type, $title, $_gids, $date) { // assertor $file_content = '<rdf:RDF xmlns:earl="http://www.w3.org/ns/earl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> <!-- Assertor --> '; $user_data = $this->getUserData(); if ($user_data) { $username = $user_data[0]; $email = $user_data[1]; $file_content .= '<foaf:Group rdf:ID="assertor01"> <dct:title>' . $username . ' and ' . _AC('file_title') . '</dct:title> <dct:hasVersion>' . VERSION . '</dct:hasVersion> <dct:description xml:lang="en"> ' . _AC('file_description') . ' </dct:description> <earl:mainAssertor rdf:resource="' . $this->achecker_url . '"/> <foaf:member> <foaf:Person> <foaf:mbox rdf:resource="mailto:' . $email . '"/> <foaf:name>' . $username . '</foaf:name> </foaf:Person> </foaf:member> </foaf:Group> '; } else { $file_content .= '<earl:Software rdf:about="' . $this->achecker_url . '"> <dct:title xml:lang="en">' . _AC('file_title') . '</dct:title> <dct:hasVersion>' . VERSION . '</dct:hasVersion> <dct:description xml:lang="en"> ' . _AC('file_description') . ' </dct:description> </earl:Software> '; } // test subject $file_content .= '<!-- Test Subject --> '; if ($input_content_type == 'file') { $file_content .= '<earl:TestSubject xml:lang="en">' . _AC('file_input_file') . '</earl:TestSubject>'; } else { if ($input_content_type == 'paste') { $file_content .= '<earl:TestSubject xml:lang="en">' . _AC('file_input_paste') . '</earl:TestSubject>'; } else { $file_content .= '<earl:TestSubject rdf:about="' . $input_content_type . '">'; $file_content .= ' <dct:title xml:lang="en">' . $title . '</dct:title>'; $file_content .= ' <dct:date>' . $date . '</dct:date> </earl:TestSubject> '; } } // test criterion $file_content .= '<!-- Test Criterion --> '; $guidelinesDAO = new GuidelinesDAO(); $guideline_rows = $guidelinesDAO->getGuidelineByIDs($_gids); // display guidelines if (is_array($guideline_rows)) { foreach ($guideline_rows as $id => $row) { $file_content .= '<earl:TestRequirement rdf:about="' . $row["earlid"] . '"> <dct:title xml:lang="en">' . $row["abbr"] . '</dct:title> <dct:description xml:lang="en">' . _AC($row["long_name"]) . '</dct:description> </earl:TestRequirement> '; } } return $file_content; }
/** * private * main process to generate report in html format */ private function generateRESTRpt() { $num_of_errors = 0; $num_of_likely_problems = 0; $num_of_potential_problems = 0; $checksDAO = new ChecksDAO(); $userDecisionsDAO = new UserDecisionsDAO(); // generate section details foreach ($this->errors as $error) { // generate each error result $result_type = ''; $repair = ''; $decision = ''; $decision_questions = ''; $decision_made = ''; $row_check = $checksDAO->getCheckByID($error["check_id"]); if ($row_check["confidence"] == KNOWN) { // only known errors have <repair> $num_of_errors++; $result_type = _AC('error'); $repair = str_replace('{REPAIR}', htmlentities(_AC($row_check["how_to_repair"])), $this->rest_repair); } else { // generate user's decision. only likely and potential problems have decisions to make $row_userDecision = $userDecisionsDAO->getByUserLinkIDAndLineNumAndColNumAndCheckID($this->userLinkID, $error["line_number"], $error["col_number"], $error['check_id']); if ($row_userDecision['decision'] == AC_DECISION_PASS || $row_userDecision['decision'] == AC_DECISION_FAIL) { if ($row_userDecision['decision'] == AC_DECISION_PASS) { $decision_text = _AC('pass'); } if ($row_userDecision['decision'] == AC_DECISION_FAIL) { $decision_text = _AC('fail'); } $decision_made = str_replace(array('{DECISIONMADE}', '{DECISIONMADEDATE}'), array(htmlentities($decision_text), $row_userDecision['last_update']), $this->rest_decision_made); } if ($row_check["confidence"] == LIKELY) { $result_type = _AC('likely_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_likely_problems++; } } if ($row_check["confidence"] == POTENTIAL) { $result_type = _AC('potential_problem'); if (!$row_userDecision || $row_userDecision['decision'] == AC_DECISION_FAIL) { $num_of_potential_problems++; } } $decision_questions = str_replace(array('{SEQUENCEID}', '{DECISIONPASS}', '{DECISIONFAIL}'), array($error['line_number'] . '_' . $error['col_number'] . '_' . $error['check_id'], htmlentities(_AC($row_check['decision_pass'])), htmlentities(_AC($row_check['decision_fail']))), $this->rest_decision_questions); $decision = $decision_questions . $decision_made; // end of generating user's decision } $result .= str_replace(array('{RESULTTYPE}', '{LINENUM}', '{COLUMNNUM}', '{BASE_HREF}', '{CHECK_ID}', '{TITLE}', '{ERRORMSG}', '{ERRORSOURCECODE}', '{REPAIR}', '{DECISION}'), array($result_type, $error["line_number"], $error["col_number"], htmlentities(AC_BASE_HREF), $error['check_id'], htmlentities(_AC("suggest_improvements")), htmlentities(_AC($row_check['err'])), htmlentities($error["html_code"], ENT_QUOTES, "UTF-8"), $repair, $decision), $this->rest_result); } // retrieve session id $userLinksDAO = new UserLinksDAO(); $row = $userLinksDAO->getByUserLinkID($this->userLinkID); $sessionID = $row['last_sessionID']; // generate guidelines $guidelinesDAO = new GuidelinesDAO(); foreach ($this->guidelineArray as $gid) { $row_guideline = $guidelinesDAO->getGuidelineByIDs($gid); $guidelines .= str_replace('{GUIDELINE}', htmlentities($row_guideline[0]['title']), $this->rest_guideline); } // find out result status: pass, fail, conditional pass if ($num_of_errors > 0) { $status = _AC('fail'); } else { if ($num_of_likely_problems + $num_of_potential_problems > 0) { $status = _AC('conditional_pass'); } else { $status = _AC('pass'); } } // generate final output $this->output = str_replace(array('{STATUS}', '{SESSIONID}', '{NUMOFERRORS}', '{NUMOFLIKELYPROBLEMS}', '{NUMOFPOTENTIALPROBLEMS}', '{GUIDELINES}', '{RESULTS}'), array($status, $sessionID, $num_of_errors, $num_of_likely_problems, $num_of_potential_problems, $guidelines, $result), $this->rest_main); }
/* */ /* This program is free software. You can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ /* as published by the Free Software Foundation. */ /************************************************************************/ // $Id$ define('AC_INCLUDE_PATH', '../include/'); include AC_INCLUDE_PATH . 'vitals.inc.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/GuidelinesDAO.class.php'; include_once AC_INCLUDE_PATH . 'classes/DAO/ChecksDAO.class.php'; $guidelinesDAO = new GuidelinesDAO(); if (isset($_POST['submit_no'])) { $msg->addFeedback('CANCELLED'); header('Location: index.php'); exit; } else { if (isset($_POST['submit_yes'])) { if ($guidelinesDAO->Delete($_POST['id'])) { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); header('Location: index.php'); exit; } } } $rows = $guidelinesDAO->getGuidelineByIDs($_GET['id']); unset($hidden_vars); $hidden_vars['id'] = $_GET['id']; require AC_INCLUDE_PATH . 'header.inc.php'; $msg->addConfirm(array('DELETE_GUIDELINE', $rows[0]['title']), $hidden_vars); $msg->printConfirm(); require AC_INCLUDE_PATH . 'footer.inc.php';