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