Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
ACHECKER-4
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorAlagwu committed Jun 15, 2018
1 parent b034983 commit 5c411dc
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 21 deletions.
11 changes: 4 additions & 7 deletions check/index.php
Expand Up @@ -195,10 +195,10 @@
}

if ($condition == '') $condition = '1';
$checksDAO = new ChecksDAO();

$sql = "SELECT COUNT(check_id) AS cnt FROM ".TABLE_PREFIX."checks WHERE $condition";
$rows = $checksDAO->getChecksByID($condition);

$rows = $dao->execute($sql);
$num_results = $rows[0]['cnt'];

$num_pages = max(ceil($num_results / $results_per_page), 1);
Expand All @@ -214,12 +214,9 @@
$results_per_page = 999999;
}

$checksDAO = new ChecksDAO();

$sql = "SELECT *
FROM ".TABLE_PREFIX."checks
WHERE $condition ORDER BY $col $order LIMIT $offset, $results_per_page";
$check_rows = $dao->execute($sql);

$check_rows = $checksDAO->getChecks($condition, $col, $order, $offset, $results_per_page);


// if prerequisite or next checks are inserted into db successfully,
Expand Down
19 changes: 18 additions & 1 deletion include/classes/DAO/ChecksDAO.class.php
Expand Up @@ -822,5 +822,22 @@ private function deleteLang($checkID, $term, $fieldName)

return true;
}

public function getChecks($condition, $col, $order, $offset, $results_per_page)
{
$sql = "SELECT * FROM ".TABLE_PREFIX.
"checks WHERE $condition
ORDER BY $col $order
LIMIT $offset, $results_per_page";

return $this->execute($sql);
}

public function getChecksByID($condition)
{
$sql = "SELECT COUNT(check_id) AS
cnt FROM ".TABLE_PREFIX."checks WHERE $condition";

}
}
?>
?>
13 changes: 13 additions & 0 deletions include/classes/DAO/LanguageTextDAO.class.php
Expand Up @@ -243,5 +243,18 @@ function getMsgByVar($variable)

return $this->execute($sql);
}

function getMsgByVarAndLang ($variable, $lang, $parent)
{
$variable = $this->addSlashes($variable);

$sql = "SELECT * FROM ".TABLE_PREFIX."
language_text WHERE variable=".$variable."
AND (language_code=".$lang."
OR language_code=".$parent.")";

return $this->execute($sql);
}

}
?>
2 changes: 1 addition & 1 deletion include/classes/Language/LanguageEditor.class.php
Expand Up @@ -275,4 +275,4 @@ function export($filename = '') {
}

}
?>
?>
26 changes: 14 additions & 12 deletions include/lib/output.inc.php
Expand Up @@ -820,17 +820,19 @@ function getTranslatedCodeStr($codes) {
$parent = Language::getParentCode($_SESSION['lang']);

/* get $_msgs_new from the DB */
$sql = 'SELECT * FROM '.TABLE_PREFIX.'language_text WHERE variable="_msgs" AND (language_code="'.$_SESSION['lang'].'" OR language_code="'.$parent.'")';
$result = mysqli_query($languagesDAO->db, $sql);
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
$rows = $languagesDAO->getMsgByVarAndLang('_msgs', $_SESSION['lang'], $parent);


if (is_array($rows))
{
$row = $rows[0];
// do not cache key as a digit (no contstant(), use string)
$_cache_msgs_new[$row['term']] = str_replace('SITE_URL/', $_base_path, $row['text']);
if (AC_DEVEL) {
$_cache_msgs_new[$row['term']] .= ' <small><small>('.$row['term'].')</small></small>';
}
}

cache_variable('_cache_msgs_new');
endcache(true, false);
}
Expand All @@ -853,14 +855,14 @@ function getTranslatedCodeStr($codes) {
if ($message == '') {
/* the language for this msg is missing: */

//$rows = $languagesDAO->getMsgByVar('_msgs');
$sql = 'SELECT * FROM '.TABLE_PREFIX.'language_text WHERE variable="_msgs"';
$result = mysqli_query($languagesDAO->db, $sql);
$i = 1;
while ($row = mysqli_fetch_assoc($result)) {
if (($row['term']) === $codes) {
$rows = $languagesDAO->getMsgByVar('_msgs');
if (is_array($rows))
{
$row = $rows[0];

if (($row['term']) === $codes)
{
$message = '['.$row['term'].']';
break;
}
}
}
Expand Down

0 comments on commit 5c411dc

Please sign in to comment.