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

Classes

  • cGuiBackendHelpbox
  • cGuiFileOverview
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiSourceEditor
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains various note classes.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @author Unknown
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * This class uses the communication collection to serve a special collection
 18:  * for notes.
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class NoteCollection extends cApiCommunicationCollection {
 24: 
 25:     /**
 26:      * Constructor to create an instance of this class.
 27:      */
 28:     public function __construct() {
 29:         parent::__construct();
 30:         $this->_setItemClass('NoteItem');
 31:     }
 32: 
 33:     /**
 34:      * Selects one or more items from the database
 35:      *
 36:      * This function only extends the where statement. See the
 37:      * original function for the parameters.
 38:      *
 39:      * @see ItemCollection::select()
 40:      * @param string $where [optional]
 41:      *         Specifies the where clause.
 42:      * @param string $group_by [optional]
 43:      *         Specifies the group by clause.
 44:      * @param string $order_by [optional]
 45:      *         Specifies the order by clause.
 46:      * @param string $limit [optional]
 47:      *         Specifies the limit by clause.
 48:      * @return bool
 49:      *         True on success, otherwise false
 50:      */
 51:     public function select($where = '', $group_by = '', $order_by = '', $limit = '') {
 52:         if ($where == '') {
 53:             $where = "comtype='note'";
 54:         } else {
 55:             $where .= " AND comtype='note'";
 56:         }
 57: 
 58:         return parent::select($where, $group_by, $order_by, $limit);
 59:     }
 60: 
 61:     /**
 62:      * Creates a new note item.
 63:      *
 64:      * @param string $itemtype
 65:      *         Item type (usually the class name)
 66:      * @param mixed $itemid
 67:      *         Item ID (usually the primary key)
 68:      * @param int $idlang
 69:      *         Language-ID
 70:      * @param string $message
 71:      *         Message to store
 72:      * @param string $category [optional]
 73:      * @return object
 74:      *         The new item
 75:      */
 76:     public function createItem($itemtype, $itemid, $idlang, $message, $category = '') {
 77:         $item = parent::create();
 78: 
 79:         $item->set('subject', 'Note Item');
 80:         $item->set('message', $message);
 81:         $item->set('comtype', 'note');
 82:         $item->store();
 83: 
 84:         $item->setProperty('note', 'itemtype', $itemtype);
 85:         $item->setProperty('note', 'itemid', $itemid);
 86:         $item->setProperty('note', 'idlang', $idlang);
 87: 
 88:         if ($category != '') {
 89:             $item->setProperty('note', 'category', $category);
 90:         }
 91: 
 92:         return $item;
 93:     }
 94: }
 95: 
 96: /**
 97:  * This class uses the communication item to serve a special item for notes.
 98:  *
 99:  * @package Core
100:  * @subpackage GenericDB_Model
101:  */
102: class NoteItem extends cApiCommunication {
103: }
104: 
105: /**
106:  * This class uses the iframe GUI class to serve a special iframe for notes.
107:  *
108:  * @package Core
109:  * @subpackage GUI
110:  */
111: class NoteView extends cHTMLIFrame {
112: 
113:     /**
114:      *
115:      * @param string $sItemType
116:      * @param string $sItemId
117:      */
118:     public function NoteView($sItemType, $sItemId) {
119:         global $sess, $cfg;
120:         cHTMLIFrame::cHTMLIFrame();
121:         $this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2"));
122:         $this->setBorder(0);
123:     }
124: }
125: 
126: /**
127:  * This class uses the div GUI class to serve a special div for note lists.
128:  *
129:  * @package Core
130:  * @subpackage GUI
131:  */
132: class NoteList extends cHTMLDiv {
133:     /**
134:      * @var bool
135:      */
136:     protected $_bDeleteable;
137: 
138:     /**
139:      * @var string
140:      */
141:     protected $_sItemType;
142: 
143:     /**
144:      * @var string
145:      */
146:     protected $_sItemId;
147: 
148:     /**
149:      * Constructor to create an instance of this class.
150:      *
151:      * @param string $sItemType
152:      * @param string $sItemId
153:      */
154:     public function __construct($sItemType, $sItemId) {
155:         parent::__construct();
156: 
157:         $this->_sItemType = $sItemType;
158:         $this->_sItemId = $sItemId;
159: 
160:         $this->appendStyleDefinition('width', '100%');
161:     }
162: 
163:     /**
164:      *
165:      * @param bool $bDeleteable
166:      */
167:     public function setDeleteable($bDeleteable) {
168:         $this->_bDeleteable = $bDeleteable;
169:     }
170: 
171:     /**
172:      * (non-PHPdoc)
173:      *
174:      * @see cHTML::toHtml()
175:      * @return string
176:      *     generated markup
177:      */
178:     public function toHtml() {
179:         global $cfg, $lang;
180: 
181:         $sItemType = $this->_sItemType;
182:         $sItemId = $this->_sItemId;
183: 
184:         $oPropertyCollection = new cApiPropertyCollection();
185:         $oPropertyCollection->select("itemtype = 'idcommunication' AND type = 'note' AND name = 'idlang' AND value = " . (int) $lang);
186: 
187:         $items = array();
188: 
189:         while ($oProperty = $oPropertyCollection->next()) {
190:             $items[] = $oProperty->get('itemid');
191:         }
192: 
193:         $oNoteItems = new NoteCollection();
194: 
195:         if (count($items) == 0) {
196:             $items[] = 0;
197:         }
198: 
199:         $oNoteItems->select('idcommunication IN (' . implode(', ', $items) . ')', '', 'created DESC');
200: 
201:         $i = array();
202:         $dark = false;
203:         while ($oNoteItem = $oNoteItems->next()) {
204:             if ($oNoteItem->getProperty('note', 'itemtype') == $sItemType && $oNoteItem->getProperty('note', 'itemid') == $sItemId) {
205:                 $j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get('idcommunication'));
206:                 $j->setAuthor($oNoteItem->get('author'));
207:                 $j->setDate($oNoteItem->get('created'));
208:                 $j->setMessage($oNoteItem->get('message'));
209:                 $j->setBackground($dark);
210:                 $j->setDeleteable($this->_bDeleteable);
211:                 $dark = !$dark;
212:                 $i[] = $j;
213:             }
214:         }
215: 
216:         $this->setContent($i);
217: 
218:         $result = parent::toHtml();
219: 
220:         return '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>' . $result . '</td></tr></table>';
221:     }
222: }
223: 
224: /**
225:  * This class uses the div GUI class to serve a special div for note list items.
226:  *
227:  * @package Core
228:  * @subpackage GUI
229:  */
230: class NoteListItem extends cHTMLDiv {
231: 
232:     /**
233:      * Constructor to create an instance of this class.
234:      *
235:      * @param string $sItemType
236:      * @param string $sItemId
237:      * @param int $iDeleteItem
238:      */
239:     public function __construct($sItemType, $sItemId, $iDeleteItem) {
240:         parent::__construct();
241:         $this->appendStyleDefinition('padding', '2px');
242:         $this->setBackground();
243:         $this->setDeleteable(true);
244: 
245:         $this->_iDeleteItem = $iDeleteItem;
246:         $this->_sItemType = $sItemType;
247:         $this->_sItemId = $sItemId;
248:     }
249: 
250:     /**
251:      *
252:      * @param bool $bDeleteable
253:      */
254:     public function setDeleteable($bDeleteable) {
255:         $this->_bDeleteable = $bDeleteable;
256:     }
257: 
258:     /**
259:      *
260:      * @param string $dark [optional]
261:      */
262:     public function setBackground($dark = false) {
263:     }
264: 
265:     /**
266:      *
267:      * @param string $sAuthor
268:      */
269:     public function setAuthor($sAuthor) {
270:         if (strlen($sAuthor) == 32) {
271:             $result = getGroupOrUserName($sAuthor);
272: 
273:             if ($result !== false) {
274:                 $sAuthor = $result;
275:             }
276:         }
277: 
278:         $this->_sAuthor = $sAuthor;
279:     }
280: 
281:     /**
282:      *
283:      * @param string|int $iDate
284:      */
285:     public function setDate($iDate) {
286:         $dateformat = getEffectiveSetting('dateformat', 'full', 'Y-m-d H:i:s');
287: 
288:         if (is_string($iDate)) {
289:             $iDate = strtotime($iDate);
290:         }
291:         $this->_sDate = date($dateformat, $iDate);
292:     }
293: 
294:     /**
295:      *
296:      * @param string $sMessage
297:      */
298:     public function setMessage($sMessage) {
299:         $this->_sMessage = $sMessage;
300:     }
301: 
302:     /**
303:      *
304:      * @see cHTML::render()
305:      * @return string
306:      *         Generated markup
307:      */
308:     public function render() {
309:         global $sess;
310:         $itemtype = $this->_sItemType;
311:         $itemid = $this->_sItemId;
312:         $deleteitem = $this->_iDeleteItem;
313: 
314:         $table = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><b>';
315:         $table .= $this->_sAuthor;
316:         $table .= '</b></td><td align="right">';
317:         $table .= $this->_sDate;
318: 
319:         if ($this->_bDeleteable == true) {
320:             $oDeleteable = new cHTMLLink();
321:             $oDeleteable->setClass("vAlignMiddle tableElement");
322:             $oDeletePic = new cHTMLImage(cRegistry::getBackendUrl() . '/images/delete.gif');
323:             $oDeleteable->setContent($oDeletePic);
324:             $oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem"));
325: 
326:             $table .= '</td><td width="1">' . $oDeleteable->render();
327:         }
328:         $table .= '</td></tr></table>';
329: 
330:         $oMessage = new cHTMLDiv();
331:         $oMessage->setContent($this->_sMessage);
332:         $oMessage->setStyle("padding-bottom: 8px; margin-top: 4px;");
333: 
334:         $this->setContent(array(
335:             $table,
336:             $oMessage
337:         ));
338: 
339:         return parent::render();
340:     }
341: }
342: 
343: /**
344:  * This class uses the link GUI class to serve a special link for notes.
345:  *
346:  * @package Core
347:  * @subpackage GUI
348:  */
349: class NoteLink extends cHTMLLink {
350: 
351:     /**
352:      *
353:      * @var string Object type
354:      */
355:     private $_sItemType;
356: 
357:     /**
358:      *
359:      * @var string Object ID
360:      */
361:     private $_sItemID;
362: 
363:     /**
364:      *
365:      * @var bool If true, shows the note history
366:      */
367:     private $_bShowHistory;
368: 
369:     /**
370:      *
371:      * @var bool If true, history items can be deleted
372:      */
373:     private $_bDeleteHistoryItems;
374: 
375:     /**
376:      * Creates a new note link item.
377:      *
378:      * This link is used to show the popup from any position within the system.
379:      * The link contains the note image.
380:      *
381:      * @param string $sItemType
382:      *         Item type (usually the class name)
383:      * @param mixed $sItemID
384:      *         Item ID (usually the primary key)
385:      */
386:     public function NoteLink($sItemType, $sItemID) {
387:         parent::__construct();
388: 
389:         $img = new cHTMLImage('images/note.gif');
390:         $img->setStyle('padding-left: 2px; padding-right: 2px;');
391: 
392:         $img->setAlt(i18n('View notes / add note'));
393:         $this->setLink('#');
394:         $this->setContent($img->render());
395:         $this->setAlt(i18n('View notes / add note'));
396: 
397:         $this->_sItemType = $sItemType;
398:         $this->_sItemID = $sItemID;
399:         $this->_bShowHistory = false;
400:         $this->_bDeleteHistoryItems = false;
401:     }
402: 
403:     /**
404:      * Enables the display of all note items
405:      */
406:     public function enableHistory() {
407:         $this->_bShowHistory = true;
408:     }
409: 
410:     /**
411:      * Disables the display of all note items
412:      */
413:     public function disableHistory() {
414:         $this->_bShowHistory = false;
415:     }
416: 
417:     /**
418:      * Enables the delete function in the history view
419:      */
420:     public function enableHistoryDelete() {
421:         $this->_bDeleteHistoryItems = true;
422:     }
423: 
424:     /**
425:      * Disables the delete function in the history view
426:      */
427:     public function disableHistoryDelete() {
428:         $this->_bDeleteHistoryItems = false;
429:     }
430: 
431:     /**
432:      * @see cHTML::render()
433:      * @return string
434:      *         Generated markup
435:      */
436:     public function render() {
437:         global $sess;
438: 
439:         $itemtype = $this->_sItemType;
440:         $itemid = $this->_sItemID;
441: 
442:         $this->setEvent('click', 'javascript:window.open(' . "'" . $sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid") . "', 'todo', 'resizable=yes,scrollbars=yes,height=360,width=550');");
443:         return parent::render();
444:     }
445: }
446: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0