source: branches/work_311/output/LetterFilterControl.cpp @ 537

Revision 537, 2.0 KB checked in by jls17, 5 years ago (diff)
  • replaced the CWebUtil::Link call in LetterFilterControl?.cpp with a call to the DirectURLLink class
Line 
1//Copyright (C) 2014 John Luthgers | jls17
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with ARInside.  If not, see <http://www.gnu.org/licenses/>.
16
17#include "stdafx.h"
18#include "LetterFilterControl.h"
19#include "../core/ARServerObject.h"
20#include "../output/URLLink.h"
21
22LetterFilterControl::LetterFilterControl()
23{
24        objCountPerLetter.resize(38); // see objectNameFirstCharLetters
25}
26
27LetterFilterControl::~LetterFilterControl()
28{
29}
30
31void LetterFilterControl::IncStartLetterOf(CARServerObject &obj)
32{
33        string firstChar = obj.GetNameFirstChar();
34        if (firstChar.empty()) firstChar = "*";
35
36        int index = CARObject::GetFirstCharIndex(firstChar[0]);
37        ++(objCountPerLetter[index]);
38}
39
40void LetterFilterControl::Render(std::ostream &strm)
41{
42        try
43        {
44                strm << "<table id='formLetterFilter'><tr>" << endl;
45
46                string strValue = objectNameFirstCharLetters; // "abcdefghijklmnopqrstuvwxyz0123456789#"
47                for (unsigned int i = 0; i < strValue.size(); ++i) 
48                {
49                        if (objCountPerLetter[i] > 0)
50                        {
51                                strm << "<td>";
52                                strm << DirectURLLink(DirectURLLink::JavascriptVoid, strValue.substr(i, 1), 0);
53                        }
54                        else
55                        {
56                                strm << "<td class=\"disabledLetter\">";
57                                strm << strValue.at(i);
58                        }
59
60                        strm << "</td>" << endl;
61                }
62
63                strm << "</tr></table>" << endl;
64        }
65        catch(exception& e)
66        {
67                cout << "EXCEPTION LetterFilterControl::Render : " << e.what() << endl;
68        }
69}
70
71ostream& operator<<(ostream& strm, OUTPUT::LetterFilterControl& inst)
72{ 
73        inst.Render(strm);
74        return strm;
75}
Note: See TracBrowser for help on using the repository browser.