added: forum
added: mount params can have arguments (in parentheses) added: mount params: withheader, withinfo, restrictcreatethread, only_root_can_remove, can_use_emacs_on(level), can_use_mkdir_on(level), added: table Item has 'subject' column now removed: column 'subject' from table Content git-svn-id: svn://ttmath.org/publicrep/cmslu/trunk@505 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
134
core/misc.cpp
134
core/misc.cpp
@@ -64,6 +64,8 @@ std::string::iterator i;
|
||||
*i = '_';
|
||||
}
|
||||
}
|
||||
|
||||
ToSmall(item.url);
|
||||
|
||||
if( item.url.empty() )
|
||||
item.url = "bez_nazwy"; // !! wrzucic do pliku konfiguracyjnego
|
||||
@@ -157,21 +159,38 @@ return c;
|
||||
}
|
||||
|
||||
|
||||
bool HtmlTryChar(std::ostringstream & out, int c)
|
||||
{
|
||||
if( c == '<' )
|
||||
{
|
||||
out << "<";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '>' )
|
||||
{
|
||||
out << ">";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if( c == '&' )
|
||||
{
|
||||
out << "&";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HtmlEscape(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
|
||||
for(i = in.begin() ; i != in.end() ; ++i)
|
||||
{
|
||||
if( *i == '<' )
|
||||
out << "<";
|
||||
else
|
||||
if( *i == '>' )
|
||||
out << ">";
|
||||
else
|
||||
if( *i == '&' )
|
||||
out << "&";
|
||||
else
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
out << *i;
|
||||
}
|
||||
}
|
||||
@@ -187,6 +206,52 @@ return out.str();
|
||||
}
|
||||
|
||||
|
||||
void HtmlEscapeFormTxt(std::ostringstream & out, const std::string & in)
|
||||
{
|
||||
std::string::const_iterator i;
|
||||
int was_enter = 0; // how many enteres there were before
|
||||
|
||||
out << "<p>";
|
||||
|
||||
for(i = in.begin() ; i != in.end() ; ++i)
|
||||
{
|
||||
if( !HtmlTryChar(out, *i) )
|
||||
{
|
||||
if( *i == 13 )
|
||||
// skipping stupid characters (\r\n\ in dos mode)
|
||||
continue;
|
||||
|
||||
if( *i == 10 )
|
||||
{
|
||||
++was_enter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( was_enter == 1 )
|
||||
out << "<br>\n";
|
||||
else
|
||||
if( was_enter > 1 )
|
||||
out << "</p>\n<p>";
|
||||
|
||||
out << *i;
|
||||
was_enter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out << "</p>\n";
|
||||
}
|
||||
|
||||
|
||||
std::string HtmlEscapeFormTxt(const std::string & in)
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
HtmlEscapeFormTxt(out, in);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
||||
const char * DateToStr(int year, int month, int day, int hour, int min, int sec)
|
||||
{
|
||||
@@ -213,7 +278,7 @@ static char buffer[100];
|
||||
|
||||
const char * DateToStr(tm * ptm)
|
||||
{
|
||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
return DateToStr(ptm->tm_year + 1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec);
|
||||
}
|
||||
|
||||
|
||||
@@ -243,4 +308,53 @@ return buffer;
|
||||
}
|
||||
|
||||
|
||||
bool IsWhite(int s)
|
||||
{
|
||||
if( s==' ' || s=='\t' || s==13 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrimWhite(std::string & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
if( s.empty() )
|
||||
return;
|
||||
|
||||
// looking for white characters at the end
|
||||
for(i=s.size()-1 ; i>0 && IsWhite(s[i]) ; --i);
|
||||
|
||||
if( i==0 && IsWhite(s[i]) )
|
||||
{
|
||||
// the whole string has white characters
|
||||
s.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// deleting white characters at the end
|
||||
if( i != s.size() - 1 )
|
||||
s.erase(i+1, std::string::npos);
|
||||
|
||||
// looking for white characters at the beginning
|
||||
for(i=0 ; i<s.size() && IsWhite(s[i]) ; ++i);
|
||||
|
||||
// deleting white characters at the beginning
|
||||
if( i != 0 )
|
||||
s.erase(0, i);
|
||||
}
|
||||
|
||||
|
||||
void ToSmall(std::string & s)
|
||||
{
|
||||
std::string::size_type i;
|
||||
|
||||
for(i=0 ; i<s.size() ; ++i)
|
||||
{
|
||||
if( s[i]>='A' && s[i]<='Z' )
|
||||
s[i] = s[i] - 'A' + 'a';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user