mirror of
https://github.com/anope/anope.git
synced 2026-06-28 08:36:37 +02:00
Translate listformatter properly
This commit is contained in:
@@ -67,9 +67,11 @@ class CoreExport ListFormatter
|
||||
public:
|
||||
typedef std::map<Anope::string, Anope::string> ListEntry;
|
||||
private:
|
||||
NickCore *nc;
|
||||
std::vector<Anope::string> columns;
|
||||
std::vector<ListEntry> entries;
|
||||
public:
|
||||
ListFormatter(NickCore *nc);
|
||||
ListFormatter &AddColumn(const Anope::string &name);
|
||||
void AddEntry(const ListEntry &entry);
|
||||
bool IsEmpty() const;
|
||||
|
||||
@@ -187,7 +187,7 @@ class CommandBSBadwords : public Command
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST";
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
BadWords *bw = ci->GetExt<BadWords>("badwords");
|
||||
|
||||
list.AddColumn("Number").AddColumn("Word").AddColumn("Type");
|
||||
|
||||
@@ -22,7 +22,7 @@ class CommandBSBotList : public Command
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
unsigned count = 0;
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn("Nick").AddColumn("Mask");
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ class CommandCSAccess : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Level").AddColumn("Mask");
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
@@ -438,7 +438,7 @@ class CommandCSAccess : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Level").AddColumn("Mask").AddColumn("By").AddColumn("Last seen");
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ class CommandCSLevels : public Command
|
||||
{
|
||||
source.Reply(_("Access level settings for channel %s:"), ci->name.c_str());
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Name").AddColumn("Level");
|
||||
|
||||
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
|
||||
@@ -754,7 +754,7 @@ class CommandCSLevels : public Command
|
||||
{
|
||||
source.Reply(_("The following feature/function names are available:"));
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Name").AddColumn("Description");
|
||||
|
||||
const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges();
|
||||
|
||||
@@ -360,7 +360,7 @@ class CommandCSAKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ class CommandCSAKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Last used").AddColumn("Reason");
|
||||
this->ProcessList(source, ci, params, list);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class CommandEntryMessage : public Command
|
||||
|
||||
source.Reply(_("Entry message list for \002%s\002:"), ci->name.c_str());
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Message");
|
||||
for (unsigned i = 0; i < (*messages)->size(); ++i)
|
||||
{
|
||||
|
||||
@@ -267,7 +267,7 @@ class CommandCSFlags : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Flags").AddColumn("Creator").AddColumn("Created");
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class CommandCSList : public Command
|
||||
|
||||
source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str());
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Name").AddColumn("Description");
|
||||
|
||||
Anope::map<ChannelInfo *> ordered_map;
|
||||
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
source.Reply(_("There currently are no logging configurations for %s."), ci->name.c_str());
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Service").AddColumn("Command").AddColumn("Method").AddColumn("");
|
||||
|
||||
for (unsigned i = 0; i < (*ls)->size(); ++i)
|
||||
|
||||
@@ -422,7 +422,7 @@ class CommandCSMode : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Mode").AddColumn("Param").AddColumn("Creator").AddColumn("Created");
|
||||
|
||||
for (ModeLocks::ModeList::const_iterator it = mlocks.begin(), it_end = mlocks.end(); it != it_end; ++it)
|
||||
|
||||
@@ -378,7 +378,7 @@ class CommandCSXOP : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask");
|
||||
|
||||
if (!nick.empty() && nick.find_first_not_of("1234567890,-") == Anope::string::npos)
|
||||
|
||||
@@ -54,7 +54,7 @@ class CommandHSList : public Command
|
||||
}
|
||||
|
||||
unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax", "50");
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Creator").AddColumn("Created");
|
||||
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
|
||||
@@ -295,7 +295,7 @@ class CommandHSWaiting : public Command
|
||||
{
|
||||
unsigned counter = 0;
|
||||
unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get<unsigned>("listmax");
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Created");
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class CommandMSIgnore : public Command
|
||||
source.Reply(_("Memo ignore list is empty."));
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Mask");
|
||||
for (unsigned i = 0; i < mi->ignores.size(); ++i)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ class CommandMSList : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn("Number").AddColumn("Sender").AddColumn("Date/Time");
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ class CommandNSAJoin : public Command
|
||||
source.Reply(_("%s's auto join list is empty."), nc->display.c_str());
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Channel").AddColumn("Key");
|
||||
for (unsigned i = 0; i < (*channels)->size(); ++i)
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ class CommandNSAList : public Command
|
||||
nc = na->nc;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
int chan_count = 0;
|
||||
|
||||
list.AddColumn("Number").AddColumn("Channel").AddColumn("Access");
|
||||
|
||||
@@ -150,7 +150,7 @@ class CommandNSCert : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Certificate");
|
||||
|
||||
for (unsigned i = 0; i < cl->GetCertCount(); ++i)
|
||||
@@ -240,7 +240,7 @@ class CommandNSCert : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Certificate");
|
||||
|
||||
for (unsigned i = 0; i < cl->GetCertCount(); ++i)
|
||||
|
||||
@@ -295,7 +295,7 @@ class CommandNSGList : public Command
|
||||
else
|
||||
nc = source.GetAccount();
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Nick").AddColumn("Expires");
|
||||
time_t nickserv_expire = Config->GetModule("nickserv")->Get<time_t>("expire");
|
||||
for (unsigned i = 0; i < nc->aliases->size(); ++i)
|
||||
|
||||
@@ -70,7 +70,7 @@ class CommandNSList : public Command
|
||||
}
|
||||
|
||||
mync = source.nc;
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
|
||||
list.AddColumn("Nick").AddColumn("Last usermask");
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ class CommandOSAKill : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
|
||||
|
||||
this->ProcessList(source, params, list);
|
||||
@@ -341,7 +341,7 @@ class CommandOSAKill : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Creator").AddColumn("Created").AddColumn("Expires").AddColumn("Reason");
|
||||
|
||||
this->ProcessList(source, params, list);
|
||||
|
||||
@@ -53,7 +53,7 @@ class CommandOSConfig : public Command
|
||||
if (!items)
|
||||
continue;
|
||||
|
||||
ListFormatter lflist;
|
||||
ListFormatter lflist(source.GetAccount());
|
||||
lflist.AddColumn("Name").AddColumn("Value");
|
||||
|
||||
for (Configuration::Block::item_map::const_iterator it = items->begin(), it_end = items->end(); it != it_end; ++it)
|
||||
|
||||
@@ -213,7 +213,7 @@ class CommandOSDNS : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
ListFormatter lf;
|
||||
ListFormatter lf(source.GetAccount());
|
||||
lf.AddColumn("Server").AddColumn("IP").AddColumn("Limit").AddColumn("State");
|
||||
for (unsigned i = 0; i < dns_servers->size(); ++i)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ class CommandOSDNS : public Command
|
||||
|
||||
if (!zones->empty())
|
||||
{
|
||||
ListFormatter lf2;
|
||||
ListFormatter lf2(source.GetAccount());
|
||||
lf2.AddColumn("Zone").AddColumn("Servers");
|
||||
|
||||
for (unsigned i = 0; i < zones->size(); ++i)
|
||||
|
||||
@@ -289,7 +289,7 @@ class CommandOSForbid : public Command
|
||||
source.Reply(_("Forbid list is empty."));
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Mask").AddColumn("Type").AddColumn("Reason");
|
||||
|
||||
for (unsigned i = 0; i < forbids.size(); ++i)
|
||||
|
||||
@@ -208,7 +208,7 @@ class CommandOSIgnore : public Command
|
||||
source.Reply(_("Ignore list is empty."));
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Mask").AddColumn("Creator").AddColumn("Reason").AddColumn("Expires");
|
||||
for (std::list<IgnoreData>::const_iterator ign = ignores.begin(), ign_end = ignores.end(); ign != ign_end; ++ign)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ class CommandOSChanList : public Command
|
||||
modes.insert("PRIVATE");
|
||||
}
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Name").AddColumn("Users").AddColumn("Modes").AddColumn("Topic");
|
||||
|
||||
if (!pattern.empty() && (u2 = User::Find(pattern, true)))
|
||||
@@ -143,7 +143,7 @@ class CommandOSUserList : public Command
|
||||
if (!opt.empty() && opt.equals_ci("INVISIBLE"))
|
||||
modes.insert("INVIS");
|
||||
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Name").AddColumn("Mask");
|
||||
|
||||
if (!pattern.empty() && (c = Channel::Find(pattern)))
|
||||
|
||||
@@ -113,7 +113,7 @@ class NewsBase : public Command
|
||||
source.Reply(msgs[MSG_LIST_NONE]);
|
||||
else
|
||||
{
|
||||
ListFormatter lflist;
|
||||
ListFormatter lflist(source.GetAccount());
|
||||
lflist.AddColumn("Number").AddColumn("Creator").AddColumn("Created").AddColumn("Text");
|
||||
|
||||
for (unsigned i = 0, end = list.size(); i < end; ++i)
|
||||
|
||||
@@ -181,7 +181,7 @@ class CommandOSSession : public Command
|
||||
source.Reply(_("Invalid threshold value. It must be a valid integer greater than 1."));
|
||||
else
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Session").AddColumn("Host");
|
||||
|
||||
for (SessionService::SessionMap::iterator it = session_service->GetSessions().begin(), it_end = session_service->GetSessions().end(); it != it_end; ++it)
|
||||
@@ -527,7 +527,7 @@ class CommandOSException : public Command
|
||||
|
||||
void DoList(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Limit").AddColumn("Mask");
|
||||
|
||||
this->ProcessList(source, params, list);
|
||||
@@ -535,7 +535,7 @@ class CommandOSException : public Command
|
||||
|
||||
void DoView(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Limit").AddColumn("Reason");
|
||||
|
||||
this->ProcessList(source, params, list);
|
||||
|
||||
@@ -183,7 +183,7 @@ class CommandOSSXLineBase : public Command
|
||||
|
||||
void OnList(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("Reason");
|
||||
|
||||
this->ProcessList(source, params, list);
|
||||
@@ -191,7 +191,7 @@ class CommandOSSXLineBase : public Command
|
||||
|
||||
void OnView(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
ListFormatter list;
|
||||
ListFormatter list(source.GetAccount());
|
||||
list.AddColumn("Number").AddColumn("Mask").AddColumn("By").AddColumn("Created").AddColumn("Expires").AddColumn("Reason");
|
||||
this->ProcessList(source, params, list);
|
||||
}
|
||||
|
||||
+12
-4
@@ -121,6 +121,10 @@ bool NumberList::InvalidRange(const Anope::string &)
|
||||
return true;
|
||||
}
|
||||
|
||||
ListFormatter::ListFormatter(NickCore *acc) : nc(acc)
|
||||
{
|
||||
}
|
||||
|
||||
ListFormatter &ListFormatter::AddColumn(const Anope::string &name)
|
||||
{
|
||||
this->columns.push_back(name);
|
||||
@@ -139,10 +143,14 @@ bool ListFormatter::IsEmpty() const
|
||||
|
||||
void ListFormatter::Process(std::vector<Anope::string> &buffer)
|
||||
{
|
||||
std::vector<Anope::string> tcolumns;
|
||||
std::map<Anope::string, size_t> lenghts;
|
||||
std::set<Anope::string> breaks;
|
||||
for (unsigned i = 0; i < this->columns.size(); ++i)
|
||||
lenghts[this->columns[i]] = this->columns[i].length();
|
||||
{
|
||||
tcolumns.push_back(Language::Translate(this->nc, this->columns[i].c_str()));
|
||||
lenghts[this->columns[i]] = tcolumns[i].length();
|
||||
}
|
||||
for (unsigned i = 0; i < this->entries.size(); ++i)
|
||||
{
|
||||
ListEntry &e = this->entries[i];
|
||||
@@ -176,9 +184,9 @@ void ListFormatter::Process(std::vector<Anope::string> &buffer)
|
||||
}
|
||||
else if (!s.empty())
|
||||
s += " ";
|
||||
s += this->columns[i];
|
||||
if (i + 1 != this->columns.size())
|
||||
for (unsigned j = this->columns[i].length(); j < lenghts[this->columns[i]]; ++j)
|
||||
s += tcolumns[i];
|
||||
if (i + 1 != this->columns.size())
|
||||
for (unsigned j = tcolumns[i].length(); j < lenghts[this->columns[i]]; ++j)
|
||||
s += " ";
|
||||
}
|
||||
buffer.push_back(s);
|
||||
|
||||
Reference in New Issue
Block a user