5 // Using static members in a class makes this combatible with PHP 5.0+ and effectively gives us a namespace
9 // Load Rico client files and create style sheet
11 static public $jsDir="../../ricoClient/js/"; // directory containing Rico's javascript files
12 static public $cssDir="../../ricoClient/css/"; // directory containing Rico's css files
13 static public $imgDir="../../ricoClient/images/"; // directory containing Rico's image files
14 static public $transDir;
15 static public $checkQueryString = false; // load settings from QueryString? true only for demo
17 // The base Javascript library to load from http://ajax.googleapis.com/ajax/libs/, possible values include:
19 // prototype/1.6/prototype.js
20 // prototype/1.7/prototype.js
21 // jquery/1.3/jquery.min.js
22 // jquery/1.4/jquery.min.js
23 // jquery/1.5/jquery.min.js
24 // jquery/1.6/jquery.min.js
25 // mootools/1.2/mootools-yui-compressed.js
26 // mootools/1.3/mootools-yui-compressed.js
27 // dojo/1.5/dojo/dojo.xd.js
28 // dojo/1.6/dojo/dojo.xd.js
29 // ext-core/3.0/ext-core.js
30 // ext-core/3.1/ext-core.js
32 // Default value is "proto_min.js", which loads prototype 1.7 from jsDir.
33 static public $BaseLib = "proto_min.js";
35 // Enable Javascript console logging? Useful for debugging. Default is false.
36 static public $Logging = false;
38 // Enable HTML5 web form elements in browsers that support them.
39 // Default is false because the quality of the HTML5 web form elements is uneven across browsers.
40 static public $HTML5 = false;
42 // Best left unset, in which case language will be set automatically based on request's HTTP_ACCEPT_LANGUAGE
43 // However, if you want to present the same locale settings to all users, then you can set this value to force the desired locale.
44 static public $Language;
46 // Load base Javascript library (prototype, jQuery, etc)?
48 // Set to false if library is being loaded another way. In this case, a BaseLib value is still required to indicate
49 // which library Rico should connect to.
50 static public $LoadBaseLib = true;
52 // Apply row striping to LiveGrids? Default is true. Applies only when themes are used.
53 static public $Striping = true;
55 // Background image for grid headings and window titles.
56 // Should be left unset, as it is used only for the grayedout theme (in which case it is set automatically).
57 static public $ImgHeading;
59 // Comma separated list of 2 letter locales that Rico supports.
60 // Do not set unless you have developed your own locale file.
61 static public $SupportedLangs = "de,es,fr,it,ja,ko,pt,ru,uk,zh";
63 // URL to load jQuery themes from.
64 // Default is http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/
65 // Override this value if you have a jQuery theme on your own server.
66 static public $jQueryThemePath = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/";
68 static public $theme; // jquery themes start with j-, rico themes start with r-
69 static protected $lang2;
72 static public function SetLocale() {
73 $lang=strtolower(isset(self::$Language) ? self::$Language : $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
74 $arLang=explode(",",$lang);
75 $transdir=isset(self::$transdir) ? self::$transdir : self::$jsDir;
76 for ($i=0; $i<count($arLang); $i++) {
77 $lang2=substr(trim($arLang[$i]),0,2);
78 if ($lang2=='en') break; // already included
79 if (strpos(self::$SupportedLangs,$lang2) !== false) {
80 //if (file_exists($fname)) {
81 $fname=$transDir."ricoLocale_".$lang2.".js";
82 echo "<script src='".$fname."' type='text/javascript'></script>\n";
86 self::$lang2 = $i<count($arLang) ? $lang2 : "en";
89 // Returns the 2 character string representing the Rico locale file that was actually used on the client.
90 // if there is no match between the requested languages and the available locale files, then english is used.
91 // Only available after renderHead has been called.
92 function LoadedLanguage() {
99 // initializes the class with the values in the options associative array
100 function init($options) {
101 foreach ($options as $property => $value) {
102 Client::$$property = $value;
106 // This function writes out the required Rico settings in the head section of the html document
107 function renderHead() {
108 if (Client::$checkQueryString) {
109 Client::$BaseLib=$_GET['lib'];
110 Client::$theme=$_GET["theme"];
111 Client::$Logging=isset($_GET["log"]);
112 Client::$HTML5=isset($_GET["html5"]);
116 if (Client::$Logging) $a[] = "enableLogging: true";
117 if (Client::$HTML5) $a[] = "enableHTML5: true";
119 echo "\n<script type='text/javascript'>\n";
120 echo "Rico_CONFIG = { " . implode(", ", $a) . " };\n";
124 if (Client::$LoadBaseLib) {
125 if (strpos(Client::$BaseLib,"/") === false) {
126 echo "<script src='".Client::$jsDir.Client::$BaseLib."' type='text/javascript'></script>\n";
128 echo "<script src='http://ajax.googleapis.com/ajax/libs/".Client::$BaseLib."' type='text/javascript'></script>\n";
131 requireRicoJS("2" . substr(Client::$BaseLib,0,3));
132 requireRicoJS("_min");
133 requireRicoCSS("rico");
139 if (isset(Client::$theme) && strlen(Client::$theme) > 2) {
140 $prefix=substr(Client::$theme,0,1);
141 $themeName=substr(Client::$theme,2);
144 requireRicoJS("Themeroller");
145 echo "<link type='text/css' rel='Stylesheet' href='" . Client::$jQueryThemePath . $themeName . "/jquery-ui.css' />\n";
148 requireRicoCSS($themeName);
151 if (Client::$Striping) {
152 echo "<link type='text/css' rel='stylesheet' href='".Client::$cssDir."striping_".$themeName.".css' />\n";
158 echo "<style type='text/css'>\n";
159 //For Each ctrl As Control In Page.Controls
160 // if TypeOf (ctrl) Is GridBase Then writer.Write(CType(ctrl, GridBase).GridRules())
161 // if TypeOf (ctrl) Is LiveGrid Then writer.Write(CType(ctrl, LiveGrid).ColumnRules())
163 if (!isset(Client::$ImgHeading) && Client::$theme=="r-grayedout") Client::$ImgHeading=Client::$imgDir."grayedout.gif";
164 if (isset(Client::$ImgHeading)) {
165 echo ".Rico_accTitle, .ricoTitle, table.ricoLiveGrid thead th, table.ricoLiveGrid thead td, tr.ricoLG_hdg td, tr.ricoLG_hdg th {\n";
166 echo " background-position: left center;\n";
167 echo " background-repeat: repeat-x;\n";
168 echo " background-image: url('" . Client::$ImgHeading . "');\n";
171 echo ".ricoLG_Resize {\n";
172 echo " background-repeat: repeat;\n";
173 echo " background-image: url('" . Client::$imgDir . "resize.gif');\n";
175 echo ".rico-icon {\n";
176 echo " background-repeat: no-repeat;\n";
177 echo " background-image: url('" . Client::$imgDir . "ricoIcons.gif');\n";
182 function requireRicoJS($filename) {
183 echo "<script src='".Client::$jsDir."rico".$filename.".js' type='text/javascript'></script>\n";
186 function requireRicoCSS($filename) {
187 echo "<link href='".Client::$cssDir.$filename.".css' type='text/css' rel='stylesheet' />\n";
191 abstract class GridBase {
194 // Name of grid Javascript object
195 public function gridVar() {
196 return $this->id . ".grid";
199 // Name of grid options Javascript object
200 public function optionsVar() {
201 return $this->id . ".options";
204 // If enabled, an additional row is added to the grid header where column filters are placed.
205 // See the EditCol.filterUI property to customize each column's filter.
206 public $AutoFilter = false;
208 // The token in select filters used to indicate "show all values" (default: "___ALL___").
209 public $FilterAllToken;
211 // if unset, then use column heading width, otherwise this is the default width in pixels
212 public $defaultWidth;
214 // Allow user to resize columns? Default is true.
215 public $allowColResize;
217 // Number of frozen columns on the left (or right if direction=rtl). Default is 0.
218 public $frozenColumns;
220 // Height of one line of text in ems. Default is 1.2, which should be fine for almost all situations.
221 public $RowLineHtEms = 1.2;
223 // Resize grid when browser window is resized? Default is true.
224 public $windowResize;
226 // Specifies when the grid's popup menu should be invoked