- yhook: remove unnecessary line feeds from plain output; ...

align control/getbouquet
This commit is contained in:
svenhoefer
2016-02-21 01:29:17 +01:00
parent 1c73ca39e7
commit 89e0ba1a41
2 changed files with 19 additions and 14 deletions

View File

@@ -1203,7 +1203,7 @@ void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) {
bool encode = false; bool encode = false;
std::string result = ""; std::string result = "";
TOutType outType = hh->outStart(true /*old mode*/); TOutType outType = hh->outStart();
if (hh->ParamList["showhidden"] == "false") if (hh->ParamList["showhidden"] == "false")
show_hidden = false; show_hidden = false;
@@ -1241,9 +1241,13 @@ void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) {
bouquet = std::string(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str()); bouquet = std::string(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str());
if (encode) if (encode)
bouquet = encodeString(bouquet); // encode (URLencode) the bouquetname bouquet = encodeString(bouquet); // encode (URLencode) the bouquetname
item = hh->outPair("number", string_printf("%u", i + 1), true); if (outType == plain)
if(outType == plain) item+= " "; item = string_printf("%u", i + 1) + " " + bouquet + "\n";
item += hh->outPair("name", bouquet, false); else
{
item = hh->outPair("number", string_printf("%u", i + 1), true);
item += hh->outPair("name", bouquet, false);
}
result += hh->outArrayItem("bouquet", item, (i < size-1)); result += hh->outArrayItem("bouquet", item, (i < size-1));
} }
} }

View File

@@ -427,31 +427,27 @@ TOutType CyhookHandler::outStart(bool single) {
std::string CyhookHandler::outIndent() { std::string CyhookHandler::outIndent() {
return ""; return "";
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string CyhookHandler::outPair(std::string _key, std::string _content, bool _next) { std::string CyhookHandler::outPair(std::string _key, std::string _content, bool _next) {
std::string result = ""; std::string result = "";
switch (outType) { switch (outType) {
case xml: case xml:
result = outIndent() + "<" + _key + ">" + _content + "</" + _key + ">"; result = outIndent() + "<" + _key + ">" + _content + "</" + _key + ">";
result += "\n";
break; break;
case json: case json:
result = outIndent() + "\"" + _key + "\": \"" + _content + "\""; result = outIndent() + "\"" + _key + "\": \"" + _content + "\"";
if(_next) if(_next)
result += ","; result += ",";
result += "\n";
break; break;
default: default:
if (outSingle) if (outSingle)
result = _content; result = _content;
else else
{
result = _key + "=" + _content; result = _key + "=" + _content;
result += "\n";
}
break; break;
} }
return result; return result + "\n";
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -461,16 +457,18 @@ std::string CyhookHandler::outArray(std::string _key, std::string _content) {
case xml: case xml:
//TODO: xml check and DESC check //TODO: xml check and DESC check
result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">"; result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">";
result += "\n";
break; break;
case json: case json:
//TODO: json check //TODO: json check
result = outIndent() + "\"" + _key + "\": [" + _content + "]"; result = outIndent() + "\"" + _key + "\": [" + _content + "]";
result += "\n";
break; break;
default: default:
result = _content; result = _content;
break; break;
} }
return result + "\n"; return result;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -480,18 +478,20 @@ std::string CyhookHandler::outArrayItem(std::string _key, std::string _content,
case xml: case xml:
//TODO: xml check and DESC check //TODO: xml check and DESC check
result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">"; result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">";
result += "\n";
break; break;
case json: case json:
//TODO: json check //TODO: json check
result = outIndent() + "{" + _content + "}"; result = outIndent() + "{" + _content + "}";
if(_next) if(_next)
result += ","; result += ",";
result += "\n";
break; break;
default: default:
result = _content; result = _content;
break; break;
} }
return result + "\n"; return result;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
std::string CyhookHandler::outCollection(std::string _key, std::string _content) { std::string CyhookHandler::outCollection(std::string _key, std::string _content) {
@@ -500,16 +500,18 @@ std::string CyhookHandler::outCollection(std::string _key, std::string _content)
case xml: case xml:
//TODO: xml check and DESC check //TODO: xml check and DESC check
result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">"; result = outIndent() + "<" + _key + ">\n" + _content + "</" + _key + ">";
result += "\n";
break; break;
case json: case json:
//TODO: json check //TODO: json check
result = outIndent() + "\"" + _key + "\": {" + _content + "}"; result = outIndent() + "\"" + _key + "\": {" + _content + "}";
result += "\n";
break; break;
default: default:
result = _content; result = _content;
break; break;
} }
return result + "\n"; return result;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -521,7 +523,6 @@ std::string CyhookHandler::outValue(std::string _content) {
break; break;
case json: case json:
result = json_convert_string(_content); result = json_convert_string(_content);
// result = _content;
break; break;
default: default: