# HG changeset patch # User Matti Hamalainen # Date 1386262123 -7200 # Node ID d2ece5d0aaa42d2df2bd0c28d1751820a274ea24 # Parent 876846d8ed5b717ccd24d6933719701d848a0720 Cleanups. diff -r 876846d8ed5b -r d2ece5d0aaa4 admajax.php --- a/admajax.php Thu Dec 05 17:55:07 2013 +0200 +++ b/admajax.php Thu Dec 05 18:48:43 2013 +0200 @@ -206,7 +206,7 @@ } -function stGetInfoCurrEntryData() +function stGetInfoCurrEntryData($indent) { $compoID = stGetDisplayVar("compoID"); if ($compoID > 0) @@ -222,13 +222,13 @@ $strCompo = $strCurrEntry = $strPrevEntry = "-"; return - "
Current compo:
".$strCompo."
\n". - "
Current entry:
".$strCurrEntry."
\n". - "
Previous entry:
".$strPrevEntry."
\n"; + $indent."
Current compo:
".$strCompo."
\n". + $indent."
Current entry:
".$strCurrEntry."
\n". + $indent."
Previous entry:
".$strPrevEntry."
\n"; } -function stGetInfoCurrEntryList() +function stGetInfoCurrEntryList($indent, $outer) { $sql = stPrepareSQL( "SELECT * FROM entries WHERE compo_id=%d ORDER BY show_id ASC", @@ -238,19 +238,48 @@ if ($currShowID <= 0) $currShowID = -1; - $str = " ".stGetOptionListStart("ctrlEntryList"); + $str = stGetOptionListStart("ctrlEntryList", $indent, $outer); if (($res = stExecSQL($sql)) !== false) { foreach ($res as $item) { - $str .= - " ".stGetOptionListItem($item["show_id"], + $str .= $indent." ". + stGetOptionListItem($item["show_id"], ($item["show_id"] == $currShowID), sprintf("%3d. %s by %s", $item["show_id"], $item["name"], $item["author"])); } } - return $str." ".stGetOptionListEnd(); + + $str .= stGetOptionListEnd($indent, $outer); + return $str; +} + + +function stGetInfoRotationLists($indent, $outer) +{ + $sql = + "SELECT rotationListData.*, ". + "(SELECT COUNT(*) FROM rotationListSlides WHERE list_id=rotationListData.id) AS nslides ". + "FROM rotationListData ". + "LEFT JOIN rotationListSlides ON rotationListData.id=rotationListSlides.list_id ". + "ORDER BY id DESC"; + + $str = stGetOptionListStart("ctrlRotationLists", $indent, $outer); + + if (($res = stExecSQL($sql)) !== false) + { + foreach ($res as $item) + { + $str .= $indent." ". + stGetOptionListItem($item["id"], + ($currListID == $item["id"]), + $item["name"]." (".$item["nslides"]." slides)"); + } + } + + $str .= stGetOptionListEnd($indent, $outer); + return $str; } @@ -260,11 +289,11 @@ } -function stGetOptionListStart($id, $size = 10, $onChange = "") +function stGetOptionListStart($id, $indent, $outer, $size = 10, $onChange = "") { return - "
\n". - "\n"; } @@ -278,9 +307,11 @@ } -function stGetOptionListEnd() +function stGetOptionListEnd($indent, $outer) { - return "\n"."
\n"; + return + $indent."\n". + ($outer ? $indent."\n" : ""); } @@ -524,11 +555,15 @@ switch ($type) { case "infoCurrEntryData": - echo stGetInfoCurrEntryData(); + echo stGetInfoCurrEntryData("", FALSE); break; case "infoCurrEntryList": - echo stGetInfoCurrEntryList(); + echo stGetInfoCurrEntryList("", FALSE); + break; + + case "infoRotationLists": + echo stGetInfoRotationLists("", FALSE); break; case "infoEditRotationList": @@ -536,7 +571,7 @@ "
\n". "
Edit rotation list
\n". " ".stGetFormTextInput(30, 128, "ctrlEDRotationListName", "", "", "")."
\n". - " ".stGetOptionListSTart("ctrlEDRotationList"); + stGetOptionListStart("ctrlEDRotationList", " ", TRUE); $sql = "SELECT * FROM displaySlides"; if (($res = stExecSQL($sql)) !== false) @@ -553,8 +588,8 @@ $list_id); echo - " ".stGetOptionListEnd(). - " ".stGetOptionListStart("ctrlEDDisplaySlides"); + stGetOptionListEnd(" ", TRUE). + stGetOptionListStart("ctrlEDDisplaySlides", " ", TRUE); if (($res = stExecSQL($sql)) !== false) { @@ -563,7 +598,7 @@ } echo - " ".stGetOptionListEnd(). + stGetOptionListEnd(" ", TRUE). "
\n". " ".stGetFormButtonInput("moveslideup", "", "", "Move Up", "moveListSlide(-1)")."\n". " ".stGetFormButtonInput("moveslidedn", "", "", "Move Down", "moveListSlide(1)")."\n". @@ -607,21 +642,7 @@ echo "
\n". "
Rotation lists:
\n". - " ".stGetOptionListStart("ctrlRotationLists"); - - $sql = - "SELECT rotationListData.* FROM rotationListData ". - "LEFT JOIN rotationListSlides ON ". - "ORDER BY id DESC"; - - if (($res = stExecSQL($sql)) !== false) - { - foreach ($res as $item) - echo " ".stGetOptionListItem($item["id"], FALSE, $item["name"]); - } - - echo - " ".stGetOptionListEnd(). + stGetInfoRotationLists(" ", TRUE). "
\n". " ".stGetFormButtonInput("actlist", "", "", "Set Active", "activateRotationList()")."\n". " ".stGetFormButtonInput("editlist", "", "", "Edit", "editRotationList()")."\n". @@ -633,7 +654,7 @@ echo "
\n". "
Display slides:
\n". - " ".stGetOptionListStart("ctrlDisplaySlides"); + stGetOptionListStart("ctrlDisplaySlides", " ", TRUE); $sql = "SELECT * FROM displaySlides ORDER BY id DESC"; if (($res = stExecSQL($sql)) !== false) @@ -643,7 +664,7 @@ } echo - " ".stGetOptionListEnd(). + stGetOptionListEnd(" ", TRUE). "
\n". " ".stGetFormTextInput(3, 5, "tempDuration", "", "", stGetDisplayVar("tempDuration"))." min\n". " ".stGetFormButtonInput("setslide", "", "", "Set Temp", "activateTempSlide()")."\n". @@ -657,7 +678,7 @@ "
\n". "
Competition control:
\n". "
\n". - " ".stGetOptionListStart("ctrlCompoList"); + stGetOptionListStart("ctrlCompoList", " ", TRUE); $sql = "SELECT compos.*, ". @@ -677,7 +698,7 @@ } echo - " ".stGetOptionListEnd(). + stGetOptionListEnd(" ", TRUE). "
\n". " ".stGetFormButtonInput("setcompo", "", "", "Change compo", "activateCompo()")."\n". "
\n". @@ -685,7 +706,7 @@ echo "
\n". - stGetInfoCurrEntryList(). + stGetInfoCurrEntryList(" ", TRUE). "
\n". " ".stGetFormButtonInput("setentry", "", "", "Set selected entry", "setSelectedEntry()")."\n". " ".stGetFormButtonInput("preventry", "", "", "Prev entry", "switchEntry(-1)")."\n". @@ -693,7 +714,7 @@ "
\n". "
\n". "
\n". - stGetInfoCurrEntryData(). + stGetInfoCurrEntryData(" "). "
\n". "
\n"; break; diff -r 876846d8ed5b -r d2ece5d0aaa4 showajax.php --- a/showajax.php Thu Dec 05 17:55:07 2013 +0200 +++ b/showajax.php Thu Dec 05 18:48:43 2013 +0200 @@ -250,5 +250,5 @@ // Save changed variables stSaveDisplayVars(); -stDumpAJAXStatusErrors(); +//stDumpAJAXStatusErrors(); ?> \ No newline at end of file