- 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;
std::string result = "";
TOutType outType = hh->outStart(true /*old mode*/);
TOutType outType = hh->outStart();
if (hh->ParamList["showhidden"] == "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());
if (encode)
bouquet = encodeString(bouquet); // encode (URLencode) the bouquetname
item = hh->outPair("number", string_printf("%u", i + 1), true);
if(outType == plain) item+= " ";
item += hh->outPair("name", bouquet, false);
if (outType == plain)
item = string_printf("%u", i + 1) + " " + bouquet + "\n";
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));
}
}

View File

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