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 scrollable lists GUI class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GUI
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Mischa Holz
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Scrollable lists GUI class
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI
 23:  */
 24: class cGuiScrollList {
 25: 
 26:     /**
 27:      * Data container
 28:      * @public array
 29:      */
 30:     public $data = Array();
 31: 
 32:     /**
 33:      * Header container
 34:      * @public array
 35:      */
 36:     public $header = Array();
 37: 
 38:     /**
 39:      * Number of records displayed per page
 40:      * @public string
 41:      */
 42:     public $resultsPerPage;
 43: 
 44:     /**
 45:      * Start page
 46:      * @public string
 47:      */
 48:     public $listStart;
 49: 
 50:     /**
 51:      * sortable flag
 52:      * @public string
 53:      */
 54:     public $sortable;
 55: 
 56:     /**
 57:      * sortlink
 58:      * @public string
 59:      */
 60:     public $sortlink;
 61: 
 62:     /**
 63:      * Table item
 64:      */
 65:     public $objTable;
 66: 
 67:     /**
 68:      * Header row
 69:      */
 70:     public $objHeaderRow;
 71: 
 72:     /**
 73:      * Header item
 74:      */
 75:     public $objHeaderItem;
 76: 
 77:     /**
 78:      * Header item
 79:      */
 80:     public $objRow;
 81: 
 82:     /**
 83:      * Header item
 84:      */
 85:     public $objItem;
 86: 
 87:     /*
 88:      * TODO: Shouldn't $area and $frame be parameters instead of global
 89:      * variables?
 90:      */
 91: 
 92:     /**
 93:      * Creates a new FrontendList object.
 94:      *
 95:      * @param $defaultstyle boolean use the default style for object
 96:      *        initializing?
 97:      */
 98:     public function __construct($defaultstyle = true, $action = "") {
 99:         global $cfg, $area, $frame;
100: 
101:         $this->resultsPerPage = 0;
102:         $this->listStart = 1;
103:         $this->sortable = false;
104: 
105:         $this->objTable = new cHTMLTable();
106:         if ($defaultstyle == true) {
107:             $this->objTable->setClass("generic");
108:             $this->objTable->updateAttributes(array(
109:                 "cellpadding" => "2"
110:             ));
111:         }
112: 
113:         $this->objHeaderRow = new cHTMLTableRow();
114: 
115:         $this->objHeaderItem = new cHTMLTableHead();
116: 
117:         $this->objRow = new cHTMLTableRow();
118: 
119:         $this->objItem = new cHTMLTableData();
120: 
121:         $this->sortlink = new cHTMLLink();
122:         $this->sortlink->setStyle("color: #666666;");
123:         $this->sortlink->setCLink($area, $frame, $action);
124:     }
125: 
126:     /**
127:      * Sets the sortable flag for a specific row.
128:      *
129:      * $obj->setSortable(true);
130:      *
131:      * @param $sortable boolean true or false
132:      */
133:     public function setSortable($key, $sortable) {
134:         $this->sortable[$key] = $sortable;
135:     }
136: 
137:     /**
138:      * Sets the custom parameters for sortable links
139:      *
140:      * $obj->setCustom($key, $custom);
141:      *
142:      * @param $key Custom entry key
143:      * @param $custom Custom entry value
144:      */
145:     public function setCustom($key, $custom) {
146:         $this->sortlink->setCustom($key, $custom);
147:     }
148: 
149:     /**
150:      * Is called when a new row is rendered
151:      *
152:      * @param $row The current row which is being rendered
153:      */
154:     public function onRenderRow($row) {
155:         $this->objRow->setStyle("white-space:nowrap;");
156:     }
157: 
158:     /**
159:      * Is called when a new column is rendered
160:      *
161:      * @param $row The current column which is being rendered
162:      */
163:     public function onRenderColumn($column) {
164:     }
165: 
166:     /**
167:      * Sets header data.
168:      *
169:      * Note: This public function eats as many parameters as you specify.
170:      *
171:      * Example:
172:      * $obj->setHeader("foo", "bar");
173:      *
174:      * Make sure that the amount of parameters stays the same for all
175:      * setData calls in a single object.
176:      *
177:      * @param $index Numeric index
178:      * @param ... Additional parameters (data)
179:      */
180:     public function setHeader() {
181:         $numargs = func_num_args();
182: 
183:         for ($i = 0; $i < $numargs; $i++) {
184:             $this->header[$i] = func_get_arg($i);
185:         }
186:     }
187: 
188:     /**
189:      * Sets data.
190:      *
191:      * Note: This public function eats as many parameters as you specify.
192:      *
193:      * Example:
194:      * $obj->setData(0, "foo", "bar");
195:      *
196:      * Make sure that the amount of parameters stays the same for all
197:      * setData calls in a single object. Also make sure that your index
198:      * starts from 0 and ends with the actual number - 1.
199:      *
200:      * @param $index int Numeric index
201:      * @param ... Additional parameters (data)
202:      */
203:     public function setData($index) {
204:         $numargs = func_num_args();
205: 
206:         for ($i = 1; $i < $numargs; $i++) {
207:             $this->data[$index][$i] = func_get_arg($i);
208:         }
209:     }
210: 
211:     /**
212:      * Sets hidden data.
213:      *
214:      * Note: This public function eats as many parameters as you specify.
215:      *
216:      * Example:
217:      * $obj->setHiddenData(0, "foo", "bar");
218:      *
219:      * Make sure that the amount of parameters stays the same for all
220:      * setData calls in a single object. Also make sure that your index
221:      * starts from 0 and ends with the actual number - 1.
222:      *
223:      * @param $index int Numeric index
224:      * @param ... Additional parameters (data)
225:      */
226:     public function setHiddenData($index) {
227:         $numargs = func_num_args();
228: 
229:         for ($i = 1; $i < $numargs; $i++) {
230:             $this->data[$index]["hiddendata"][$i] = func_get_arg($i);
231:         }
232:     }
233: 
234:     /**
235:      * Sets the number of records per page.
236:      *
237:      * @param $numresults int Amount of records per page
238:      */
239:     public function setResultsPerPage($numresults) {
240:         $this->resultsPerPage = $numresults;
241:     }
242: 
243:     /**
244:      * Sets the starting page number.
245:      *
246:      * @param $startpage int Page number on which the list display starts
247:      */
248:     public function setListStart($startpage) {
249:         $this->listStart = $startpage;
250:     }
251: 
252:     /**
253:      * Returns the current page.
254:      *
255:      * @param $none
256:      * @return s Current page number
257:      */
258:     public function getCurrentPage() {
259:         if ($this->resultsPerPage == 0) {
260:             return 1;
261:         }
262: 
263:         return ($this->listStart);
264:     }
265: 
266:     /**
267:      * Returns the amount of pages.
268:      *
269:      * @param $none
270:      * @return s Amount of pages
271:      */
272:     public function getNumPages() {
273:         return (ceil(count($this->data) / $this->resultsPerPage));
274:     }
275: 
276:     /**
277:      * Sorts the list by a given field and a given order.
278:      *
279:      * @param $field int Field index
280:      * @param $order string|int Sort order (see php's sort documentation)
281:      */
282:     public function sort($field, $order) {
283:         if ($order == "") {
284:             $order = SORT_ASC;
285:         }
286: 
287:         if ($order == "ASC") {
288:             $order = SORT_ASC;
289:         }
290: 
291:         if ($order == "DESC") {
292:             $order = SORT_DESC;
293:         }
294: 
295:         $this->sortkey = $field;
296:         $this->sortmode = $order;
297: 
298:         $field = $field + 1;
299:         $this->data = cArray::csort($this->data, "$field", $order);
300:     }
301: 
302:     /**
303:      * Field converting facility.
304:      * Needs to be overridden in the child class to work properbly.
305:      *
306:      * @param $field Field index
307:      * @param $value Field value
308:      */
309:     public function convert($field, $value, $hiddendata) {
310:         return $value;
311:     }
312: 
313:     /**
314:      * Outputs or optionally returns
315:      *
316:      * @param $return If true, returns the list
317:      */
318:     public function render($return = true) {
319:         global $cfg;
320: 
321:         $currentpage = $this->getCurrentPage();
322: 
323:         $itemstart = (($currentpage - 1) * $this->resultsPerPage) + 1;
324: 
325:         $headeroutput = "";
326:         $output = "";
327: 
328:         /* Render header */
329:         foreach ($this->header as $key => $value) {
330:             if (is_array($this->sortable)) {
331:                 if (array_key_exists($key, $this->sortable) && $this->sortable[$key] == true) {
332:                     $this->sortlink->setContent($value);
333:                     $this->sortlink->setCustom("sortby", $key);
334: 
335:                     if ($this->sortkey == $key && $this->sortmode == SORT_ASC) {
336:                         $this->sortlink->setCustom("sortmode", "DESC");
337:                     } else {
338:                         $this->sortlink->setCustom("sortmode", "ASC");
339:                     }
340: 
341:                     $this->objHeaderItem->setContent($this->sortlink->render());
342:                     $headeroutput .= $this->objHeaderItem->render();
343:                 } else {
344:                     $this->objHeaderItem->setContent($value);
345:                     $headeroutput .= $this->objHeaderItem->render();
346:                 }
347:             } else {
348:                 $this->objHeaderItem->setContent($value);
349:                 $headeroutput .= $this->objHeaderItem->render();
350:             }
351:             $this->objHeaderItem->advanceID();
352:         }
353: 
354:         $this->objHeaderRow->setContent($headeroutput);
355: 
356:         $headeroutput = $this->objHeaderRow->render();
357: 
358:         if ($this->resultsPerPage == 0) {
359:             $itemend = count($this->data) - ($itemstart - 1);
360:         } else {
361:             $itemend = $currentpage * $this->resultsPerPage;
362:         }
363: 
364:         if ($itemend > count($this->data)) {
365:             $itemend = count($this->data);
366:         }
367: 
368:         for ($i = $itemstart; $i < $itemend + 1; $i++) {
369: 
370:             // At the last entry we get NULL as result
371:             // This produce an error, therefore use continue
372:             if ($this->data[$i - 1] == NULL) {
373:                 continue;
374:             }
375: 
376:             $items = "";
377: 
378:             $this->onRenderRow($i);
379: 
380:             foreach ($this->data[$i - 1] as $key => $value) {
381:                 $this->onRenderColumn($key);
382: 
383:                 if ($key != "hiddendata") {
384:                     $hiddendata = $this->data[$i - 1]["hiddendata"];
385: 
386:                     $this->objItem->setContent($this->convert($key, $value, $hiddendata));
387:                     $items .= $this->objItem->render();
388:                 }
389:                 $this->objItem->advanceID();
390:             }
391: 
392:             $this->objRow->setContent($items);
393:             $items = "";
394: 
395:             $output .= $this->objRow->render();
396:             $this->objRow->advanceID();
397:         }
398: 
399:         $this->objTable->setContent($headeroutput . $output);
400: 
401:         $output = stripslashes($this->objTable->render());
402: 
403:         if ($return == true) {
404:             return $output;
405:         } else {
406:             echo $output;
407:         }
408:     }
409: 
410: }
411: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen