Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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

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