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