1/**
2 * This class centralize the pfc resources (translated messages, images, themes ...)
3 * (depends on prototype library)
4 * @author Stephane Gully
5 */
6var pfcResource = Class.create();
7pfcResource.prototype = {
8
9  initialize: function()
10  {
11    this.labels  = $H();
12    this.fileurl = $H();
13    this.smileys = $H();
14    this.smileysreverse = $H();
15    this.smileyskeys = new Array();
16  },
17
18  setLabel: function(key, value)
19  {
20    this.labels.set(key,value);
21  },
22
23  getLabel: function()
24  {
25    var key = this.getLabel.arguments[0];
26    if (this.labels.get(key))
27    {
28      this.getLabel.arguments[0] = this.labels.get(key);
29      return String.sprintf2(this.getLabel.arguments);
30    }
31    else
32      return '_'+key+'_';
33  },
34
35  setFileUrl: function(key, value)
36  {
37    this.fileurl.set(key,value);
38  },
39
40  getFileUrl: function(key)
41  {
42    if (this.fileurl.get(key))
43      return this.fileurl.get(key);
44    else
45      return "";
46  },
47
48  setSmiley: function(key, value)
49  {
50    this.smileys.set(key, value);
51    this.smileysreverse.set(value,key);
52    this.smileyskeys.push(key);
53  },
54  getSmiley: function(key)
55  {
56    if (this.smileys.get(key))
57      return this.smileys.get(key);
58    else
59      return "";
60  },
61  getSmileyHash: function()
62  {
63    return this.smileys;
64  },
65  getSmileyReverseHash: function()
66  {
67    return this.smileysreverse;
68  },
69  getSmileyKeys: function()
70  {
71    return this.smileyskeys;
72  },
73  sortSmileyKeys: function()
74  {
75    // Sort keys by longest to shortest. This prevents a smiley like :) from being used on >:)
76    return this.smileyskeys.sort(
77        function (a,b)
78        {
79          var x = a.unescapeHTML();
80          var y = b.unescapeHTML();
81
82          // Replace " with " for IE and Webkit browsers.
83          // The prototype.js version 1.5.1.1 unescapeHTML() function does not do this.
84          if (is_ie || is_webkit)
85          {
86            x = x.replace(/"/g,'"');
87            y = y.replace(/"/g,'"');
88          }
89
90          return (y.length - x.length);
91        }
92    );
93  }
94};
95
96
97