Files
chocomae/src/web/php/db/menu_collection.php
T
2019-09-15 19:25:42 +09:00

293 lines
6.8 KiB
PHP

<?php
class MenuCollection extends DBMethodContainer
{
public function getAppGroupName($appGroupCode)
{
switch(intval($appGroupCode)) {
case 0:
return "finger position";
case 1:
return "typing practice";
case 2:
return "typing test";
case 3:
return "typing play";
case 4:
return "mouse play";
}
}
public function getLanguageName($language)
{
switch(intval($language)) {
case 0:
return "Korean";
case 1:
return "English";
}
}
public function getTypingAppType($appGroupCode, $language)
{
switch(intval($appGroupCode)) {
case 0: // typing finger position"
if(intval($language) === 0) // Korean
return 1;
else // English
return 2;
case 1: // typing practice
if(intval($language) === 0) // Korean
return 11;
else // English
return 12;
case 3: // typing play
if(intval($language) === 0) // Korean
return 51;
else // English
return 52;
}
}
// app list
public function getAppList($maestroID, $playerID, $appGroup, $language)
{
switch($appGroup) {
case 0: // typing finger position
case 1: // typing practice
case 3: // typing play
return $this->getTypingAppList($maestroID, $playerID, $appGroup, $language);
case 2:
// return $this->getTypingExamWritingList($maestroID, $playerID, $appGroup, $language);
case 4: // mouse play
// return $this->getMouseAppList($maestroID, $playerID, $appGroup);
}
}
public function getTypingAppList($maestroID, $playerID, $appGroup, $language)
{
/*
$query = "
SELECT A.AppID, A.AppName, A.KoreanName, A.AppType
FROM app AS A
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = ? AND AA.MaestroID=?";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("ii", $this->getTypingAppType($appGroup, $language), $maestroID);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $korean_name, $app_type);
$resultArray = array();
while($stmt->fetch()) {
$rowArray = array();
$rowArray["AppID"] = $app_id;
$rowArray["AppName"] = $app_name;
$rowArray["KoreanName"] = $korean_name;
$rowArray["AppType"] = $app_type;
array_push($resultArray, $rowArray);
}
$stmt->close();
*/
$query = "
SELECT A.AppID, A.KoreanName
FROM app AS A
WHERE A.AppType=? AND A.Status=1";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("i", $this->getTypingAppType($appGroup, $language));
$stmt->execute();
$stmt->bind_result($appID, $koreanName);
$resultArray = array();
while($stmt->fetch()) {
$rowArray = array();
$rowArray["appID"] = $appID;
$rowArray["koreanName"] = $koreanName;
array_push($resultArray, $rowArray);
}
$stmt->close();
return $resultArray;
}
public function getMouseAppList($maestroID, $playerID, $appGroup, $language)
{
}
public function getTypingExamWritingList($maestroID, $playerID, $appGroup, $language)
{
}
// active app list
public function getActiveAppList($maestroID, $playerID, $appGroup, $language)
{
switch($appGroup) {
case 0: // typing finger position
case 1: // typing practice
case 3: // typing play
return $this->getTypingActiveAppList($maestroID, $playerID, $appGroup, $language);
case 2:
// return $this->getTypingExamWritingList($maestroID, $playerID, $appGroup, $language);
break;
case 4: // mouse play
// return $this->getMouseActiveAppList($maestroID, $playerID, $appGroup);
}
}
public function getTypingActiveAppList($maestroID, $playerID, $appGroup, $language)
{
$query = "
SELECT A.AppID
FROM app AS A
INNER JOIN active_app AS AA ON A.AppID = AA.AppID AND A.AppType = ? AND AA.MaestroID=?";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("ii", $this->getTypingAppType($appGroup, $language), $maestroID);
$stmt->execute();
$stmt->bind_result($appID);
$resultArray = array();
while($stmt->fetch()) {
$rowArray = array();
$rowArray["appID"] = $appID;
array_push($resultArray, $rowArray);
}
$stmt->close();
return $resultArray;
}
public function getMouseActiveAppList($maestroID, $playerID, $appGroup, $language)
{
return null;
}
// highest record list
public function getHighestRecordList($maestroID, $playerID, $appList)
{
switch($appGroup) {
case 0: // typing finger position
case 1: // typing practice
return $this->getTypingHighestRecordList($maestroID, $playerID, $appList);
case 2:
// return $this->getTypingExamHighestRecordWritingList($maestroID, $playerID, $appGroup, $language);
case 3: // typing play
case 4: // mouse play
return null;
break;
}
}
public function getTypingHighestRecordList($maestroID, $playerID, $appList)
{
$highestRecordArray = array();
$count = count($appList);
for($i = 0; $i < $count; $i++) {
$appID = $appList[$i]["appID"];
$highestRecord["appID"] = $appID;
$highestRecord["HighestRecord"] = $this->getTypingHighestRecord($maestroID, $playerID, $appID);
array_push($highestRecordArray, $highestRecord);
}
return $highestRecordArray;
}
public function getTypingHighestRecord($maestroID, $playerID, $appID)
{
$query = "
SELECT HighestRecord
FROM app_highest_record
WHERE MaestroID=? AND PlayerID=? AND AppID=?";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("iii", $maestroID, $playerID, $appID);
$stmt->execute();
$stmt->bind_result($highestRecord);
$returnValue = $stmt->fetch();
$stmt->close();
if($returnValue === NULL || $returnValue === FALSE)
return 0;
return $highestRecord;
}
public function getTypingExamHighestRecordWritingList($maestroID, $playerID, $appGroup, $language)
{
return null;
}
/*
public function getSystemWritingList()
{
$writer = "system";
$query = "
SELECT WritingID, Language, Name, Filename, LetterCount
FROM writing
WHERE Writer = ?";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("s", $writer);
$stmt->execute();
$stmt->bind_result($writingID, $language, $name, $filename, $letterCount);
$resultArray = array();
while($stmt->fetch()) {
$rowArray = array();
$rowArray["writingID"] = $writingID;
$rowArray["language"] = $language;
$rowArray["name"] = $name;
$rowArray["filename"] = $filename;
$rowArray["letterCount"] = $letterCount;
array_push($resultArray, $rowArray);
}
$stmt->close();
return $resultArray;
}
public function getWritingInfo($writingID)
{
$query = "
SELECT Name, Filename, Writer, WriterID
FROM writing
WHERE WritingID = ?";
$stmt = $this->mysqli->prepare($query);
$stmt->bind_param("i", $writingID);
$stmt->execute();
$stmt->bind_result($name, $filename, $writer, $writerID);
$stmt->fetch();
$stmt->close();
$rowArray = array();
$rowArray["name"] = $name;
$rowArray["filename"] = $filename;
$rowArray["writer"] = $writer;
$rowArray["writerID"] = $writerID;
return $rowArray;
}
*/
}
?>