Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the the input helper classes.
  4:  * Various derived HTML class elements especially useful
  5:  * in the input area of modules
  6:  * Simple table generation class especially useful to generate
  7:  * backend configuration table. May be used also in Frontend,
  8:  * but note the globally used variables ($cfg)
  9:  *
 10:  * @package    Core
 11:  * @subpackage Util
 12:  * @version    SVN Revision $Rev:$
 13:  *
 14:  * @author     Bjoern Behrens
 15:  * @copyright  four for business AG <www.4fb.de>
 16:  * @license    http://www.contenido.org/license/LIZENZ.txt
 17:  * @link       http://www.4fb.de
 18:  * @link       http://www.contenido.org
 19:  */
 20: 
 21: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 22: 
 23: /**
 24:  * Select box with additional functions for category and article selection
 25:  *
 26:  * @package Core
 27:  * @subpackage Util
 28:  */
 29: class cHTMLInputSelectElement extends cHTMLSelectElement {
 30: 
 31:     /**
 32:      * Constructor.
 33:      * Creates an HTML select field (aka 'DropDown').
 34:      *
 35:      * @param string $sName Name of the element
 36:      * @param int $iWidth Width of the select element
 37:      * @param string $sID ID of the element
 38:      * @param string $bDisabled Item disabled flag (non-empty to set disabled)
 39:      * @param int $iTabIndex Tab index for form elements
 40:      * @param string $sAccessKey Key to access the field
 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:      * Function addArticles.
 48:      * Adds articles to select box values.
 49:      *
 50:      * @param int $iIDCat idcat of the category to be listed
 51:      * @param bool $bColored Add color information to option elements
 52:      * @param bool $bArtOnline If true, only online articles will be added
 53:      * @param string $sSpaces Just some '&nbsp;' to show data hierarchically
 54:      *        (used in conjunction with addCategories)
 55:      *
 56:      * @return int Number of items added
 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:                     // Generate new option element
 88:                     $oOption = new cHTMLOptionElement($sSpaces . '&nbsp;&nbsp;&nbsp;' . 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:                                 // Start article, but offline -> red
 94:                                 $oOption->setStyle('color: #ff0000;');
 95:                             } else {
 96:                                 // Start article -> blue
 97:                                 $oOption->setStyle('color: #0000ff;');
 98:                             }
 99:                         } else if ($oDB->f('online') == 0) {
100:                             // Offline article -> grey
101:                             $oOption->setStyle('color: #666666;');
102:                         }
103:                     }
104: 
105:                     // Add option element to the list
106:                     $this->addOptionElement($iCounter, $oOption);
107:                     $iCounter++;
108:                 }
109:                 return $iCount;
110:             }
111:         } else {
112:             return 0;
113:         }
114:     }
115: 
116:     /**
117:      * Function addCategories.
118:      * Adds category elements (optionally including articles) to select box
119:      * values.
120:      * Note: Using 'with articles' adds the articles also - but the categories
121:      * will get a negative value!
122:      * There is no way to distinguish between a category id and an article id...
123:      *
124:      * @param int $iMaxLevel Max. level shown (to be exact: except this level)
125:      * @param bool $bColored Add color information to option elements
126:      * @param bool $bCatVisible If true, only add idcat as value, if cat is
127:      *        visible
128:      * @param bool $bCatPublic If true, only add idcat as value, if cat is
129:      *        public
130:      * @param bool $bWithArt Add also articles per category
131:      * @param bool $bArtOnline If true, show only online articles
132:      *
133:      * @return int Number of items added
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 .= '&nbsp;&nbsp;&nbsp;';
163:                 }
164: 
165:                 // Generate new option element
166:                 if (($bCatVisible && $oDB->f('visible') == 0) || ($bCatPublic && $oDB->f('public') == 0)) {
167:                     // If category has to be visible or public and it isn't,
168:                     // don't add value
169:                     $sValue = '';
170:                 } else if ($bWithArt) {
171:                     // If article will be added, set negative idcat as value
172:                     $sValue = '-' . $iID;
173:                 } else {
174:                     // Show only categories - and everything is fine...
175:                     $sValue = $iID;
176:                 }
177:                 $oOption = new cHTMLOptionElement($sSpaces . '>&nbsp;' . $oDB->f('name'), $sValue);
178: 
179:                 // Coloring option element, restricted shows grey color
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:                 // Add option element to the list
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:      * Function addTypesFromArt.
200:      * Adds types and type ids which are available for the specified article
201:      *
202:      * @param int $iIDCatArt Article id
203:      * @param string $sTypeRange Komma separated list of CONTENIDO type ids
204:      *        which may be in the resulting list (e.g. '1', '17', '28')
205:      *
206:      * @return int Number of items added
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:                     // Generate new option element
237:                     $oOption = new cHTMLOptionElement($oDB->f('type') . "[" . $oDB->f('typeid') . "]: " . substr(strip_tags($oDB->f("value")), 0, 50), $sTypeIdentifier);
238: 
239:                     // Add option element to the list
240:                     $this->addOptionElement($sTypeIdentifier, $oOption);
241:                 }
242:                 return $iCount;
243:             }
244:         } else {
245:             return false;
246:         }
247:     }
248: 
249:     /**
250:      * Selects specified elements as selected
251:      *
252:      * @param array $aElements Array with "values" of the cHTMLOptionElement to
253:      *        set
254:      * @return cHTMLSelectElement $this for chaining
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:  * Config table class.
275:  *
276:  * @package Core
277:  * @subpackage Util
278:  */
279: class UI_Config_Table {
280: 
281:     /**
282:      *
283:      * @var string
284:      */
285:     var $_sTplCellCode;
286: 
287:     /**
288:      *
289:      * @var string
290:      */
291:     var $_sTplTableFile;
292: 
293:     /**
294:      *
295:      * @var string
296:      */
297:     var $_sWidth;
298: 
299:     /**
300:      *
301:      * @var int
302:      */
303:     var $_sBorder;
304: 
305:     /**
306:      *
307:      * @var string
308:      */
309:     var $_sBorderColor;
310: 
311:     /**
312:      *
313:      * @var string
314:      */
315:     var $_bSolidBorder;
316: 
317:     /**
318:      *
319:      * @var int
320:      */
321:     var $_sPadding;
322: 
323:     /**
324:      *
325:      * @var array
326:      */
327:     var $_aCells;
328: 
329:     /**
330:      *
331:      * @var array
332:      */
333:     var $_aCellAlignment;
334: 
335:     /**
336:      *
337:      * @var array
338:      */
339:     var $_aCellVAlignment;
340: 
341:     /**
342:      *
343:      * @var unknown_type
344:      */
345:     var $_aCellColSpan;
346: 
347:     /**
348:      *
349:      * @var array
350:      */
351:     var $_aCellClass;
352: 
353:     /**
354:      *
355:      * @var unknown_type
356:      */
357:     var $_aRowBgColor;
358: 
359:     /**
360:      *
361:      * @var unknown_type
362:      */
363:     var $_aRowExtra;
364: 
365:     /**
366:      *
367:      * @var bool
368:      */
369:     var $_bAddMultiSelJS;
370: 
371:     /**
372:      *
373:      * @var unknown_type
374:      */
375:     var $_sColorLight;
376: 
377:     /**
378:      *
379:      * @var unknown_type
380:      */
381:     var $_sColorDark;
382: 
383:     /**
384:      * Create a config table instance.
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:      * @param string $sCode
400:      */
401:     function setCellTemplate($sCode) {
402:         $this->_sTplCellCode = $sCode;
403:     }
404: 
405:     /**
406:      *
407:      * @param string $sPath
408:      */
409:     function setTableTemplateFile($sPath) {
410:         $this->_sTplTableFile = $sPath;
411:     }
412: 
413:     /**
414:      *
415:      * @param unknown_type $sRow
416:      * @param unknown_type $sCell
417:      * @param unknown_type $sContent
418:      */
419:     function setCell($sRow, $sCell, $sContent) {
420:         $this->_aCells[$sRow][$sCell] = $sContent;
421:         $this->_aCellAlignment[$sRow][$sCell] = "";
422:     }
423: 
424:     /**
425:      *
426:      * @param unknown_type $sRow
427:      * @param unknown_type $sCell
428:      * @param unknown_type $sAlignment
429:      */
430:     function setCellAlignment($sRow, $sCell, $sAlignment) {
431:         $this->_aCellAlignment[$sRow][$sCell] = $sAlignment;
432:     }
433: 
434:     /**
435:      *
436:      * @param unknown_type $sRow
437:      * @param unknown_type $sCell
438:      * @param unknown_type $sAlignment
439:      */
440:     function setCellVAlignment($sRow, $sCell, $sAlignment) {
441:         $this->_aCellVAlignment[$sRow][$sCell] = $sAlignment;
442:     }
443: 
444:     /**
445:      *
446:      * @param unknown_type $sRow
447:      * @param unknown_type $sCell
448:      * @param unknown_type $sClass
449:      */
450:     function setCellClass($sRow, $sCell, $sClass) {
451:         $this->_aCellClass[$sRow][$sCell] = $sClass;
452:     }
453: 
454:     /**
455:      *
456:      * @return string
457:      */
458:     function _addMultiSelJS() {
459:         // Trick: To save multiple selections in <select>-Element, add some JS
460:         // which saves the
461:         // selection, comma separated in a hidden input field on change.
462:         // Try ... catch prevents error messages, if function is added more than
463:         // once
464:         // if (!fncUpdateSel) in JS has not worked...
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:      * @param unknown_type $bPrint
494:      * @return Ambigous <string, mixed>
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:                 // $bDark = !$bDark;
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:                     // Multi selection javascript
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:                 // Row
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: ?>
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen