1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
20:
21: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
22:
23: 24: 25: 26: 27: 28:
29: class cHTMLInputSelectElement extends cHTMLSelectElement {
30:
31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41:
42: public function __construct($sName, $iWidth = "", $sID = "", $bDisabled = false, $iTabIndex = null, $sAccessKey = "") {
43: parent::__construct($sName, $iWidth, $sID, $bDisabled, $iTabIndex, $sAccessKey);
44: }
45:
46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58:
59: public function addArticles($iIDCat, $bColored = false, $bArtOnline = true, $sSpaces = "") {
60: global $cfg, $lang;
61:
62: $oDB = cRegistry::getDb();
63:
64: if (is_numeric($iIDCat) && $iIDCat > 0) {
65: $sSQL = "SELECT tblArtLang.title AS title, tblArtLang.idartlang AS idartlang, tblCatArt.idcat AS idcat, ";
66: $sSQL .= "tblCatArt.idcatart AS idcatart, tblCatArt.is_start AS isstart, tblArtLang.online AS online, ";
67: $sSQL .= "tblCatLang.startidartlang as idstartartlang ";
68: $sSQL .= "FROM " . $cfg["tab"]["art_lang"] . " AS tblArtLang, " . $cfg["tab"]["cat_art"] . " AS tblCatArt, ";
69: $sSQL .= $cfg["tab"]["cat_lang"] . " AS tblCatLang ";
70: $sSQL .= "WHERE tblCatArt.idcat = '" . cSecurity::toInteger($iIDCat) . "' AND tblCatLang.idcat = tblCatArt.idcat AND tblCatLang.idlang = tblArtLang.idlang AND ";
71:
72: if ($bArtOnline) {
73: $sSQL .= "tblArtLang.online = '1' AND ";
74: }
75:
76: $sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . cSecurity::escapeDB($lang, $oDB) . "' ORDER BY tblArtLang.title";
77:
78: $oDB->query($sSQL);
79:
80: $iCount = $oDB->numRows();
81: if ($iCount == 0) {
82: return 0;
83: } else {
84: $iCounter = count($this->_options);
85: while ($oDB->nextRecord()) {
86:
87: $oOption = new cHTMLOptionElement($sSpaces . " " . substr($oDB->f("title"), 0, 32), $oDB->f("idcatart"));
88:
89: if ($bColored) {
90: if ($oDB->f("idstartartlang") == $oDB->f("idartlang")) {
91: if ($oDB->f("online") == 0) {
92:
93: $oOption->setStyle("color: #ff0000;");
94: } else {
95:
96: $oOption->setStyle("color: #0000ff;");
97: }
98: } else if ($oDB->f("online") == 0) {
99:
100: $oOption->setStyle("color: #666666;");
101: }
102: }
103:
104:
105: $this->addOptionElement($iCounter, $oOption);
106: $iCounter++;
107: }
108: return $iCount;
109: }
110: } else {
111: return 0;
112: }
113: }
114:
115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134:
135: public function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true, $bWithArt = false, $bArtOnline = true) {
136: global $cfg, $client, $lang;
137:
138: $oDB = cRegistry::getDb();
139:
140: $sSQL = "SELECT tblCat.idcat AS idcat, tblCatLang.name AS name, ";
141: $sSQL .= "tblCatLang.visible AS visible, tblCatLang.public AS public, tblCatTree.level AS level ";
142: $sSQL .= "FROM " . $cfg["tab"]["cat"] . " AS tblCat, " . $cfg["tab"]["cat_lang"] . " AS tblCatLang, ";
143: $sSQL .= $cfg["tab"]["cat_tree"] . " AS tblCatTree ";
144: $sSQL .= "WHERE tblCat.idclient = '" . cSecurity::escapeDB($client, $oDB) . "' AND tblCatLang.idlang = '" . cSecurity::escapeDB($lang, $oDB) . "' AND ";
145: $sSQL .= "tblCatLang.idcat = tblCat.idcat AND tblCatTree.idcat = tblCat.idcat ";
146:
147: if ($iMaxLevel > 0) {
148: $sSQL .= "AND tblCatTree.level < '" . cSecurity::escapeDB($iMaxLevel, $oDB) . "' ";
149: }
150: $sSQL .= "ORDER BY tblCatTree.idtree";
151:
152: $oDB->query($sSQL);
153:
154: $iCount = $oDB->numRows();
155: if ($iCount == 0) {
156: return false;
157: } else {
158: $iCounter = count($this->_options);
159: while ($oDB->nextRecord()) {
160: $sSpaces = "";
161: $sStyle = "";
162: $iID = $oDB->f("idcat");
163:
164: for ($i = 0; $i < $oDB->f("level"); $i++) {
165: $sSpaces .= " ";
166: }
167:
168:
169: if (($bCatVisible && $oDB->f("visible") == 0) || ($bCatPublic && $oDB->f("public") == 0)) {
170:
171:
172: $sValue = "";
173: } else if ($bWithArt) {
174:
175: $sValue = "-" . $iID;
176: } else {
177:
178: $sValue = $iID;
179: }
180: $oOption = new cHTMLOptionElement($sSpaces . "> " . $oDB->f("name"), $sValue);
181:
182:
183: $oOption->setStyle("background-color: #EFEFEF");
184: if ($bColored && ($oDB->f("visible") == 0 || $oDB->f("public") == 0)) {
185: $oOption->setStyle("color: #666666;");
186: }
187:
188:
189: $this->addOptionElement($iCounter, $oOption);
190:
191: if ($bWithArt) {
192: $iArticles = $this->addArticles($iID, $bColored, $bArtOnline, $sSpaces);
193: $iCount += $iArticles;
194: }
195: $iCounter = count($this->_options);
196: }
197: }
198: return $iCount;
199: }
200:
201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211:
212: public function addTypesFromArt($iIDCatArt, $sTypeRange = "") {
213: global $cfg, $lang;
214:
215: $oDB = cRegistry::getDb();
216:
217: if (is_numeric($iIDCatArt) && $iIDCatArt > 0) {
218: $sSQL = "SELECT tblContent.typeid AS typeid, tblContent.idtype AS idtype, tblType.type AS type, tblType.description AS description, ";
219: $sSQL .= "tblContent.value AS value ";
220: $sSQL .= "FROM " . $cfg["tab"]["content"] . " AS tblContent, " . $cfg["tab"]["art_lang"] . " AS tblArtLang, ";
221: $sSQL .= $cfg["tab"]["cat_art"] . " AS tblCatArt, " . $cfg["tab"]["type"] . " AS tblType ";
222: $sSQL .= "WHERE tblContent.idtype = tblType.idtype AND tblContent.idartlang = tblArtLang.idartlang AND ";
223: $sSQL .= "tblArtLang.idart = tblCatArt.idart AND tblArtLang.idlang = '" . cSecurity::escapeDB($lang, $oDB) . "' AND tblCatArt.idcatart = '" . cSecurity::toInteger($iIDCatArt) . "' ";
224:
225: if ($sTypeRange != "") {
226: $sSQL .= "AND tblContent.idtype IN (" . cSecurity::escapeDB($sTypeRange, $oDB) . ") ";
227: }
228:
229: $sSQL .= "ORDER BY tblContent.idtype, tblContent.typeid";
230:
231: $oDB->query($sSQL);
232:
233: $iCount = $oDB->numRows();
234: if ($iCount == 0) {
235: return false;
236: } else {
237: while ($oDB->nextRecord()) {
238: $sTypeIdentifier = "tblData.idtype = '" . $oDB->f('idtype') . "' AND tblData.typeid = '" . $oDB->f('typeid') . "'";
239:
240:
241: $oOption = new cHTMLOptionElement($oDB->f('type') . "[" . $oDB->f('typeid') . "]: " . substr(strip_tags($oDB->f("value")), 0, 50), $sTypeIdentifier);
242:
243:
244: $this->addOptionElement($sTypeIdentifier, $oOption);
245: }
246: return $iCount;
247: }
248: } else {
249: return false;
250: }
251: }
252:
253: 254: 255: 256: 257: 258: 259: 260:
261: public function setSelected($aElements) {
262: if (is_array($this->_options) && is_array($aElements)) {
263: foreach ($this->_options as $sKey => $oOption) {
264: if (in_array($oOption->getAttribute("value"), $aElements)) {
265: $oOption->setSelected(true);
266: $this->_options[$sKey] = $oOption;
267: } else {
268: $oOption->setSelected(false);
269: $this->_options[$sKey] = $oOption;
270: }
271: }
272: }
273: }
274:
275: }
276:
277: 278: 279: 280: 281: 282:
283: class UI_Config_Table {
284:
285: var $_sTplCellCode;
286:
287: var $_sTplTableFile;
288:
289: var $_sWidth;
290:
291: var $_sBorder;
292:
293: var $_sBorderColor;
294:
295: var $_bSolidBorder;
296:
297: var $_sPadding;
298:
299: var $_aCells;
300:
301: var $_aCellAlignment;
302:
303: var $_aCellVAlignment;
304:
305: var $_aCellColSpan;
306:
307: var $_aCellClass;
308:
309: var $_aRowBgColor;
310:
311: var ;
312:
313: var $_bAddMultiSelJS;
314:
315: var $_sColorLight;
316:
317: var $_sColorDark;
318:
319: function UI_Config_Table() {
320: global $cfg;
321: $backendPath = cRegistry::getBackendPath();
322:
323: $this->_sPadding = 2;
324: $this->_sBorder = 0;
325: $this->_sTplCellCode = ' <td align="{ALIGN}" valign="{VALIGN}" class="{CLASS}" colspan="{COLSPAN}" style="{EXTRA}white-space:nowrap;" nowrap="nowrap">{CONTENT}</td>' . "\n";
326: $this->_sTplTableFile = $backendPath . $cfg['path']['templates'] . $cfg['templates']['input_helper'];
327: $this->_sTplCellCode = $backendPath . $cfg['path']['templates'] . $cfg['templates']['input_helper_row'];
328: }
329:
330: function setCellTemplate($sCode) {
331: $this->_sTplCellCode = $sCode;
332: }
333:
334: function setTableTemplateFile($sPath) {
335: $this->_sTplTableFile = $sPath;
336: }
337:
338: function setCell($sRow, $sCell, $sContent) {
339: $this->_aCells[$sRow][$sCell] = $sContent;
340: $this->_aCellAlignment[$sRow][$sCell] = "";
341: }
342:
343: function setCellAlignment($sRow, $sCell, $sAlignment) {
344: $this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
345: }
346:
347: function setCellVAlignment($sRow, $sCell, $sAlignment) {
348: $this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
349: }
350:
351: function setCellClass($sRow, $sCell, $sClass) {
352: $this->_aCellClass[$sRow][$sCell] = $sClass;
353: }
354:
355: function _addMultiSelJS() {
356:
357:
358:
359:
360:
361:
362: $sSkript = ' <script type="text/javascript"><!--' . "\n" . ' try {' . "\n" . ' function fncUpdateSel(sSelectBox, sStorage)' . "\n" . ' {' . "\n" . ' var sSelection = "";' . "\n" . ' var oSelectBox = document.getElementsByName(sSelectBox)[0];' . "\n" . ' var oStorage = document.getElementsByName(sStorage)[0];' . "\n" . ' ' . "\n" . ' if (oSelectBox && oStorage)' . "\n" . ' {' . "\n" . ' for (i = 0; i < oSelectBox.length; i++)' . "\n" . ' {' . "\n" . ' if (oSelectBox.options[i].selected == true)' . "\n" . ' {' . "\n" . ' if (sSelection != "")' . "\n" . ' sSelection = sSelection + ",";' . "\n" . ' sSelection = sSelection + oSelectBox.options[i].value;' . "\n" . ' }' . "\n" . ' }' . "\n" . ' oStorage.value = sSelection;' . "\n" . ' }' . "\n" . ' }' . "\n" . ' } catch (e) { }' . "\n" . ' //--></script>' . "\n";
363:
364: return $sSkript;
365: }
366:
367: function render($bPrint = false) {
368: $oTable = new cTemplate();
369: $oTable->reset();
370:
371: $iColCount = 0;
372: $bDark = false;
373: $sBgColor = "";
374: $bMultiSelJSAdded = false;
375: if (is_array($this->_aCells)) {
376: foreach ($this->_aCells as $sRow => $aCells) {
377: $iColCount++;
378:
379: $sLine = "";
380: $iCount = 0;
381:
382: foreach ($aCells as $sCell => $sData) {
383: $iCount++;
384: $tplCell = new cTemplate();
385: $tplCell->reset();
386:
387: if ($this->_aCellClass[$sRow][$sCell] != "") {
388: $tplCell->set("s", "CLASS", $this->_aCellClass[$sRow][$sCell]);
389: } else {
390: $tplCell->set("s", "CLASS", "");
391: }
392:
393: if ($this->_aCellAlignment[$sRow][$sCell] != "") {
394: $tplCell->set("s", "ALIGN", $this->_aCellAlignment[$sRow][$sCell]);
395: } else {
396: $tplCell->set("s", "ALIGN", "left");
397: }
398:
399: if ($this->_aCellVAlignment[$sRow][$sCell] != "") {
400: $tplCell->set("s", "VALIGN", $this->_aCellAlignment[$sRow][$sCell]);
401: } else {
402: $tplCell->set("s", "VALIGN", "top");
403: }
404:
405:
406: if ($this->_bAddMultiSelJS) {
407: $sData = $this->_addMultiSelJS() . $sData;
408: $this->_bAddMultiSelJS = false;
409: }
410:
411: $tplCell->set("s", "CONTENT", $sData);
412: $sLine .= $tplCell->generate($this->_sTplCellCode, true, false);
413: }
414:
415:
416: $oTable->set('d', 'ROWS', $sLine);
417:
418: $oTable->next();
419: }
420: }
421: $sRendered = $oTable->generate($this->_sTplTableFile, true, false);
422:
423: if ($bPrint == true) {
424: echo $sRendered;
425: } else {
426: return $sRendered;
427: }
428: }
429:
430: }
431:
432: ?>