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: $sql = "SELECT al.title AS title, al.idartlang AS idartlang, ca.idcat AS idcat,
66: ca.idcatart AS idcatart, ca.is_start AS isstart, al.online AS online,
67: cl.startidartlang AS idstartartlang
68: FROM " . $cfg["tab"]["art_lang"] . " AS al, " . $cfg["tab"]["cat_art"] . " AS ca,
69: " . $cfg["tab"]["cat_lang"] . " AS cl
70: WHERE ca.idcat = '" . cSecurity::toInteger($iIDCat) . "' AND cl.idcat = ca.idcat
71: AND cl.idlang = al.idlang AND ";
72:
73: if ($bArtOnline) {
74: $sql .= "al.online = 1 AND ";
75: }
76:
77: $sql .= "al.idart = ca.idart AND al.idlang = " . (int) $lang . " ORDER BY al.title";
78:
79: $oDB->query($sql);
80:
81: $iCount = $oDB->numRows();
82: if ($iCount == 0) {
83: return 0;
84: } else {
85: $iCounter = count($this->_options);
86: while ($oDB->nextRecord()) {
87:
88: $oOption = new cHTMLOptionElement($sSpaces . ' ' . substr($oDB->f('title'), 0, 32), $oDB->f('idcatart'));
89:
90: if ($bColored) {
91: if ($oDB->f('idstartartlang') == $oDB->f('idartlang')) {
92: if ($oDB->f('online') == 0) {
93:
94: $oOption->setStyle('color: #ff0000;');
95: } else {
96:
97: $oOption->setStyle('color: #0000ff;');
98: }
99: } else if ($oDB->f('online') == 0) {
100:
101: $oOption->setStyle('color: #666666;');
102: }
103: }
104:
105:
106: $this->addOptionElement($iCounter, $oOption);
107: $iCounter++;
108: }
109: return $iCount;
110: }
111: } else {
112: return 0;
113: }
114: }
115:
116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135:
136: public function addCategories($iMaxLevel = 0, $bColored = false, $bCatVisible = true, $bCatPublic = true, $bWithArt = false, $bArtOnline = true) {
137: global $cfg, $client, $lang;
138:
139: $oDB = cRegistry::getDb();
140:
141: $sql = "SELECT c.idcat AS idcat, cl.name AS name, cl.visible AS visible, cl.public AS public, ct.level AS level
142: FROM " . $cfg["tab"]["cat"] . " AS c, " . $cfg["tab"]["cat_lang"] . " AS cl, " . $cfg["tab"]["cat_tree"] . " AS ct
143: WHERE c.idclient = " . (int) $client . " AND cl.idlang = " . (int) $lang . " AND cl.idcat = c.idcat AND ct.idcat = c.idcat ";
144: if ($iMaxLevel > 0) {
145: $sql .= "AND ct.level < " . (int) $iMaxLevel . " ";
146: }
147: $sql .= "ORDER BY ct.idtree";
148:
149: $oDB->query($sql);
150:
151: $iCount = $oDB->numRows();
152: if ($iCount == 0) {
153: return false;
154: } else {
155: $iCounter = count($this->_options);
156: while ($oDB->nextRecord()) {
157: $sSpaces = '';
158: $sStyle = '';
159: $iID = $oDB->f('idcat');
160:
161: for ($i = 0; $i < $oDB->f('level'); $i++) {
162: $sSpaces .= ' ';
163: }
164:
165:
166: if (($bCatVisible && $oDB->f('visible') == 0) || ($bCatPublic && $oDB->f('public') == 0)) {
167:
168:
169: $sValue = '';
170: } else if ($bWithArt) {
171:
172: $sValue = '-' . $iID;
173: } else {
174:
175: $sValue = $iID;
176: }
177: $oOption = new cHTMLOptionElement($sSpaces . '> ' . $oDB->f('name'), $sValue);
178:
179:
180: $oOption->setStyle('background-color: #EFEFEF');
181: if ($bColored && ($oDB->f('visible') == 0 || $oDB->f('public') == 0)) {
182: $oOption->setStyle('color: #666666;');
183: }
184:
185:
186: $this->addOptionElement($iCounter, $oOption);
187:
188: if ($bWithArt) {
189: $iArticles = $this->addArticles($iID, $bColored, $bArtOnline, $sSpaces);
190: $iCount += $iArticles;
191: }
192: $iCounter = count($this->_options);
193: }
194: }
195: return $iCount;
196: }
197:
198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208:
209: public function addTypesFromArt($iIDCatArt, $sTypeRange = '') {
210: global $cfg, $lang;
211:
212: $oDB = cRegistry::getDb();
213:
214: if (is_numeric($iIDCatArt) && $iIDCatArt > 0) {
215: $sql = "SELECT t.typeid AS typeid, t.idtype AS idtype, t.type AS type, t.description AS description, t.value AS value
216: FROM " . $cfg["tab"]["content"] . " AS t, " . $cfg["tab"]["art_lang"] . " AS al,
217: " . $cfg["tab"]["cat_art"] . " AS ca, " . $cfg["tab"]["type"] . " AS t
218: WHERE t.idtype = t.idtype AND t.idartlang = al.idartlang AND al.idart = ca.idart
219: AND al.idlang = " . (int) $lang . " AND ca.idcatart = " . (int) $iIDCatArt . " ";
220:
221: if ($sTypeRange != "") {
222: $sql .= "AND t.idtype IN (" . $oDB->escape($sTypeRange) . ") ";
223: }
224:
225: $sql .= "ORDER BY t.idtype, t.typeid";
226:
227: $oDB->query($sql);
228:
229: $iCount = $oDB->numRows();
230: if ($iCount == 0) {
231: return false;
232: } else {
233: while ($oDB->nextRecord()) {
234: $sTypeIdentifier = "tblData.idtype = '" . $oDB->f('idtype') . "' AND tblData.typeid = '" . $oDB->f('typeid') . "'";
235:
236:
237: $oOption = new cHTMLOptionElement($oDB->f('type') . "[" . $oDB->f('typeid') . "]: " . substr(strip_tags($oDB->f("value")), 0, 50), $sTypeIdentifier);
238:
239:
240: $this->addOptionElement($sTypeIdentifier, $oOption);
241: }
242: return $iCount;
243: }
244: } else {
245: return false;
246: }
247: }
248:
249: 250: 251: 252: 253: 254: 255:
256: public function setSelected($aElements) {
257: if (is_array($this->_options) && is_array($aElements)) {
258: foreach ($this->_options as $sKey => $oOption) {
259: if (in_array($oOption->getAttribute("value"), $aElements)) {
260: $oOption->setSelected(true);
261: $this->_options[$sKey] = $oOption;
262: } else {
263: $oOption->setSelected(false);
264: $this->_options[$sKey] = $oOption;
265: }
266: }
267: }
268: return $this;
269: }
270:
271: }
272:
273: 274: 275: 276: 277: 278:
279: class UI_Config_Table {
280:
281: 282: 283: 284:
285: var $_sTplCellCode;
286:
287: 288: 289: 290:
291: var $_sTplTableFile;
292:
293: 294: 295: 296:
297: var $_sWidth;
298:
299: 300: 301: 302:
303: var $_sBorder;
304:
305: 306: 307: 308:
309: var $_sBorderColor;
310:
311: 312: 313: 314:
315: var $_bSolidBorder;
316:
317: 318: 319: 320:
321: var $_sPadding;
322:
323: 324: 325: 326:
327: var $_aCells;
328:
329: 330: 331: 332:
333: var $_aCellAlignment;
334:
335: 336: 337: 338:
339: var $_aCellVAlignment;
340:
341: 342: 343: 344:
345: var $_aCellColSpan;
346:
347: 348: 349: 350:
351: var $_aCellClass;
352:
353: 354: 355: 356:
357: var $_aRowBgColor;
358:
359: 360: 361: 362:
363: var ;
364:
365: 366: 367: 368:
369: var $_bAddMultiSelJS;
370:
371: 372: 373: 374:
375: var $_sColorLight;
376:
377: 378: 379: 380:
381: var $_sColorDark;
382:
383: 384: 385:
386: function UI_Config_Table() {
387: global $cfg;
388: $backendPath = cRegistry::getBackendPath();
389:
390: $this->_sPadding = 2;
391: $this->_sBorder = 0;
392: $this->_sTplCellCode = ' <td align="{ALIGN}" valign="{VALIGN}" class="{CLASS}" colspan="{COLSPAN}" style="{EXTRA}white-space:nowrap;" nowrap="nowrap">{CONTENT}</td>' . "\n";
393: $this->_sTplTableFile = $backendPath . $cfg['path']['templates'] . $cfg['templates']['input_helper'];
394: $this->_sTplCellCode = $backendPath . $cfg['path']['templates'] . $cfg['templates']['input_helper_row'];
395: }
396:
397: 398: 399: 400:
401: function setCellTemplate($sCode) {
402: $this->_sTplCellCode = $sCode;
403: }
404:
405: 406: 407: 408:
409: function setTableTemplateFile($sPath) {
410: $this->_sTplTableFile = $sPath;
411: }
412:
413: 414: 415: 416: 417: 418:
419: function setCell($sRow, $sCell, $sContent) {
420: $this->_aCells[$sRow][$sCell] = $sContent;
421: $this->_aCellAlignment[$sRow][$sCell] = "";
422: }
423:
424: 425: 426: 427: 428: 429:
430: function setCellAlignment($sRow, $sCell, $sAlignment) {
431: $this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
432: }
433:
434: 435: 436: 437: 438: 439:
440: function setCellVAlignment($sRow, $sCell, $sAlignment) {
441: $this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
442: }
443:
444: 445: 446: 447: 448: 449:
450: function setCellClass($sRow, $sCell, $sClass) {
451: $this->_aCellClass[$sRow][$sCell] = $sClass;
452: }
453:
454: 455: 456: 457:
458: function _addMultiSelJS() {
459:
460:
461:
462:
463:
464:
465: $sSkript = '
466: <script type="text/javascript"><!--
467: try {
468: function fncUpdateSel(sSelectBox, sStorage) {
469: var sSelection = "";
470: var oSelectBox = document.getElementsByName(sSelectBox)[0];
471: var oStorage = document.getElementsByName(sStorage)[0];
472: if (oSelectBox && oStorage) {
473: for (i = 0; i < oSelectBox.length; i++) {
474: if (oSelectBox.options[i].selected == true) {
475: if (sSelection != "") {
476: sSelection = sSelection + ",";
477: }
478: sSelection = sSelection + oSelectBox.options[i].value;
479: }
480: }
481: oStorage.value = sSelection;
482: }
483: }
484: } catch (e) { }
485: //--></script>
486: ';
487:
488: return $sSkript;
489: }
490:
491: 492: 493: 494: 495:
496: function render($bPrint = false) {
497: $oTable = new cTemplate();
498: $oTable->reset();
499:
500: $iColCount = 0;
501: $bDark = false;
502: $sBgColor = "";
503: $bMultiSelJSAdded = false;
504: if (is_array($this->_aCells)) {
505: foreach ($this->_aCells as $sRow => $aCells) {
506: $iColCount++;
507:
508: $sLine = '';
509: $iCount = 0;
510:
511: foreach ($aCells as $sCell => $sData) {
512: $iCount++;
513: $tplCell = new cTemplate();
514: $tplCell->reset();
515:
516: if ($this->_aCellClass[$sRow][$sCell] != '') {
517: $tplCell->set('s', 'CLASS', $this->_aCellClass[$sRow][$sCell]);
518: } else {
519: $tplCell->set('s', 'CLASS', '');
520: }
521:
522: if ($this->_aCellAlignment[$sRow][$sCell] != '') {
523: $tplCell->set('s', 'ALIGN', $this->_aCellAlignment[$sRow][$sCell]);
524: } else {
525: $tplCell->set('s', 'ALIGN', 'left');
526: }
527:
528: if ($this->_aCellVAlignment[$sRow][$sCell] != '') {
529: $tplCell->set('s', 'VALIGN', $this->_aCellAlignment[$sRow][$sCell]);
530: } else {
531: $tplCell->set('s', 'VALIGN', 'top');
532: }
533:
534:
535: if ($this->_bAddMultiSelJS) {
536: $sData = $this->_addMultiSelJS() . $sData;
537: $this->_bAddMultiSelJS = false;
538: }
539:
540: $tplCell->set('s', 'CONTENT', $sData);
541: $sLine .= $tplCell->generate($this->_sTplCellCode, true, false);
542: }
543:
544:
545: $oTable->set('d', 'ROWS', $sLine);
546:
547: $oTable->next();
548: }
549: }
550: $sRendered = $oTable->generate($this->_sTplTableFile, true, false);
551:
552: if ($bPrint == true) {
553: echo $sRendered;
554: } else {
555: return $sRendered;
556: }
557: }
558:
559: }
560:
561: ?>