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