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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • 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:      * Constructor to create an instance of this class.
 26:      *
 27:      * @throws cInvalidArgumentException
 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:      *
 42:      * @param string $where    [optional]
 43:      *                         Specifies the where clause.
 44:      * @param string $group_by [optional]
 45:      *                         Specifies the group by clause.
 46:      * @param string $order_by [optional]
 47:      *                         Specifies the order by clause.
 48:      * @param string $limit    [optional]
 49:      *                         Specifies the limit by clause.
 50:      *
 51:      * @return bool
 52:      *         True on success, otherwise false
 53:      * 
 54:      * @throws cDbException
 55:      */
 56:     public function select($where = '', $group_by = '', $order_by = '', $limit = '') {
 57:         if ($where == '') {
 58:             $where = "comtype='note'";
 59:         } else {
 60:             $where .= " AND comtype='note'";
 61:         }
 62: 
 63:         return parent::select($where, $group_by, $order_by, $limit);
 64:     }
 65: 
 66:     /**
 67:      * Creates a new note item.
 68:      *
 69:      * @param string $itemtype
 70:      *                         Item type (usually the class name)
 71:      * @param mixed  $itemid
 72:      *                         Item ID (usually the primary key)
 73:      * @param int    $idlang
 74:      *                         Language-ID
 75:      * @param string $message
 76:      *                         Message to store
 77:      * @param string $category [optional]
 78:      *                         
 79:      * @return object
 80:      *                         The new item
 81:      * 
 82:      * @throws cDbException
 83:      * @throws cException
 84:      * @throws cInvalidArgumentException
 85:      */
 86:     public function createItem($itemtype, $itemid, $idlang, $message, $category = '') {
 87:         $item = parent::create();
 88: 
 89:         $item->set('subject', 'Note Item');
 90:         $item->set('message', $message);
 91:         $item->set('comtype', 'note');
 92:         $item->store();
 93: 
 94:         $item->setProperty('note', 'itemtype', $itemtype);
 95:         $item->setProperty('note', 'itemid', $itemid);
 96:         $item->setProperty('note', 'idlang', $idlang);
 97: 
 98:         if ($category != '') {
 99:             $item->setProperty('note', 'category', $category);
100:         }
101: 
102:         return $item;
103:     }
104: }
105: 
106: /**
107:  * This class uses the communication item to serve a special item for notes.
108:  *
109:  * @package Core
110:  * @subpackage GenericDB_Model
111:  */
112: class NoteItem extends cApiCommunication {
113: }
114: 
115: /**
116:  * This class uses the iframe GUI class to serve a special iframe for notes.
117:  *
118:  * @package Core
119:  * @subpackage GUI
120:  */
121: class NoteView extends cHTMLIFrame {
122: 
123:     /**
124:      *
125:      * @param string $sItemType
126:      * @param string $sItemId
127:      */
128:     public function __construct($sItemType, $sItemId) {
129:         global $sess;
130:         parent::__construct();
131:         $this->setSrc($sess->url("main.php?itemtype=$sItemType&itemid=$sItemId&area=note&frame=2"));
132:         $this->setBorder(0);
133:     }
134: }
135: 
136: /**
137:  * This class uses the div GUI class to serve a special div for note lists.
138:  *
139:  * @package Core
140:  * @subpackage GUI
141:  */
142: class NoteList extends cHTMLDiv {
143:     /**
144:      * @var bool
145:      */
146:     protected $_bDeleteable;
147: 
148:     /**
149:      * @var string
150:      */
151:     protected $_sItemType;
152: 
153:     /**
154:      * @var string
155:      */
156:     protected $_sItemId;
157: 
158:     /**
159:      * Constructor to create an instance of this class.
160:      *
161:      * @param string $sItemType
162:      * @param string $sItemId
163:      */
164:     public function __construct($sItemType, $sItemId) {
165:         parent::__construct();
166: 
167:         $this->_sItemType = $sItemType;
168:         $this->_sItemId = $sItemId;
169: 
170:         $this->appendStyleDefinition('width', '100%');
171:     }
172: 
173:     /**
174:      *
175:      * @param bool $bDeleteable
176:      */
177:     public function setDeleteable($bDeleteable) {
178:         $this->_bDeleteable = $bDeleteable;
179:     }
180: 
181:     /**
182:      * (non-PHPdoc)
183:      *
184:      * @see cHTML::toHtml()
185:      * 
186:      * @return string
187:      *     generated markup
188:      * 
189:      * @throws cDbException
190:      * @throws cException
191:      */
192:     public function toHtml() {
193:         global $lang;
194: 
195:         $sItemType = $this->_sItemType;
196:         $sItemId = $this->_sItemId;
197: 
198:         $oPropertyCollection = new cApiPropertyCollection();
199:         $oPropertyCollection->select("itemtype = 'idcommunication' AND type = 'note' AND name = 'idlang' AND value = " . (int) $lang);
200: 
201:         $items = array();
202: 
203:         while ($oProperty = $oPropertyCollection->next()) {
204:             $items[] = $oProperty->get('itemid');
205:         }
206: 
207:         $oNoteItems = new NoteCollection();
208: 
209:         if (count($items) == 0) {
210:             $items[] = 0;
211:         }
212: 
213:         $oNoteItems->select('idcommunication IN (' . implode(', ', $items) . ')', '', 'created DESC');
214: 
215:         $i = array();
216:         $dark = false;
217:         while ($oNoteItem = $oNoteItems->next()) {
218:             if ($oNoteItem->getProperty('note', 'itemtype') == $sItemType && $oNoteItem->getProperty('note', 'itemid') == $sItemId) {
219:                 $j = new NoteListItem($sItemType, $sItemId, $oNoteItem->get('idcommunication'));
220:                 $j->setAuthor($oNoteItem->get('author'));
221:                 $j->setDate($oNoteItem->get('created'));
222:                 $j->setMessage($oNoteItem->get('message'));
223:                 $j->setBackground($dark);
224:                 $j->setDeleteable($this->_bDeleteable);
225:                 $dark = !$dark;
226:                 $i[] = $j;
227:             }
228:         }
229: 
230:         $this->setContent($i);
231: 
232:         $result = parent::toHtml();
233: 
234:         return '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td>' . $result . '</td></tr></table>';
235:     }
236: }
237: 
238: /**
239:  * This class uses the div GUI class to serve a special div for note list items.
240:  *
241:  * @package Core
242:  * @subpackage GUI
243:  */
244: class NoteListItem extends cHTMLDiv {
245: 
246:     /**
247:      * Constructor to create an instance of this class.
248:      *
249:      * @param string $sItemType
250:      * @param string $sItemId
251:      * @param int $iDeleteItem
252:      */
253:     public function __construct($sItemType, $sItemId, $iDeleteItem) {
254:         parent::__construct();
255:         $this->appendStyleDefinition('padding', '2px');
256:         $this->setBackground();
257:         $this->setDeleteable(true);
258: 
259:         $this->_iDeleteItem = $iDeleteItem;
260:         $this->_sItemType = $sItemType;
261:         $this->_sItemId = $sItemId;
262:     }
263: 
264:     /**
265:      *
266:      * @param bool $bDeleteable
267:      */
268:     public function setDeleteable($bDeleteable) {
269:         $this->_bDeleteable = $bDeleteable;
270:     }
271: 
272:     /**
273:      *
274:      * @param bool $dark [optional]
275:      */
276:     public function setBackground($dark = false) {
277:     }
278: 
279:     /**
280:      *
281:      * @param string $sAuthor
282:      */
283:     public function setAuthor($sAuthor) {
284:         if (cString::getStringLength($sAuthor) == 32) {
285:             $result = getGroupOrUserName($sAuthor);
286: 
287:             if ($result !== false) {
288:                 $sAuthor = $result;
289:             }
290:         }
291: 
292:         $this->_sAuthor = $sAuthor;
293:     }
294: 
295:     /**
296:      *
297:      * @param string|int $iDate
298:      */
299:     public function setDate($iDate) {
300:         $dateformat = getEffectiveSetting('dateformat', 'full', 'Y-m-d H:i:s');
301: 
302:         if (cSecurity::isString($iDate)) {
303:             $iDate = strtotime($iDate);
304:         }
305:         $this->_sDate = date($dateformat, $iDate);
306:     }
307: 
308:     /**
309:      *
310:      * @param string $sMessage
311:      */
312:     public function setMessage($sMessage) {
313:         $this->_sMessage = $sMessage;
314:     }
315: 
316:     /**
317:      *
318:      * @see cHTML::render()
319:      * @return string
320:      *         Generated markup
321:      */
322:     public function render() {
323:         global $sess;
324:         $itemtype = $this->_sItemType;
325:         $itemid = $this->_sItemId;
326:         $deleteitem = $this->_iDeleteItem;
327: 
328:         $table = '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td><b>';
329:         $table .= $this->_sAuthor;
330:         $table .= '</b></td><td align="right">';
331:         $table .= $this->_sDate;
332: 
333:         if ($this->_bDeleteable == true) {
334:             $oDeleteable = new cHTMLLink();
335:             $oDeleteable->setClass("vAlignMiddle tableElement");
336:             $oDeletePic = new cHTMLImage(cRegistry::getBackendUrl() . '/images/delete.gif');
337:             $oDeleteable->setContent($oDeletePic);
338:             $oDeleteable->setLink($sess->url("main.php?frame=2&area=note&itemtype=$itemtype&itemid=$itemid&action=note_delete&deleteitem=$deleteitem"));
339: 
340:             $table .= '</td><td width="1">' . $oDeleteable->render();
341:         }
342:         $table .= '</td></tr></table>';
343: 
344:         $oMessage = new cHTMLDiv();
345:         $oMessage->setContent($this->_sMessage);
346:         $oMessage->setStyle("padding-bottom: 8px; margin-top: 4px;");
347: 
348:         $this->setContent(array(
349:             $table,
350:             $oMessage
351:         ));
352: 
353:         return parent::render();
354:     }
355: }
356: 
357: /**
358:  * This class uses the link GUI class to serve a special link for notes.
359:  *
360:  * @package Core
361:  * @subpackage GUI
362:  */
363: class NoteLink extends cHTMLLink {
364: 
365:     /**
366:      *
367:      * @var string Object type
368:      */
369:     private $_sItemType;
370: 
371:     /**
372:      *
373:      * @var string Object ID
374:      */
375:     private $_sItemID;
376: 
377:     /**
378:      *
379:      * @var bool If true, shows the note history
380:      */
381:     private $_bShowHistory;
382: 
383:     /**
384:      *
385:      * @var bool If true, history items can be deleted
386:      */
387:     private $_bDeleteHistoryItems;
388: 
389:     /**
390:      * Creates a new note link item.
391:      *
392:      * This link is used to show the popup from any position within the system.
393:      * The link contains the note image.
394:      *
395:      * @param string $sItemType
396:      *         Item type (usually the class name)
397:      * @param mixed $sItemID
398:      *         Item ID (usually the primary key)
399:      */
400:     public function __construct($sItemType, $sItemID) {
401:         parent::__construct();
402: 
403:         $img = new cHTMLImage('images/note.gif');
404:         $img->setStyle('padding-left: 2px; padding-right: 2px;');
405: 
406:         $img->setAlt(i18n('View notes / add note'));
407:         $this->setLink('#');
408:         $this->setContent($img->render());
409:         $this->setAlt(i18n('View notes / add note'));
410: 
411:         $this->_sItemType = $sItemType;
412:         $this->_sItemID = $sItemID;
413:         $this->_bShowHistory = false;
414:         $this->_bDeleteHistoryItems = false;
415:     }
416: 
417:     /**
418:      * Enables the display of all note items
419:      */
420:     public function enableHistory() {
421:         $this->_bShowHistory = true;
422:     }
423: 
424:     /**
425:      * Disables the display of all note items
426:      */
427:     public function disableHistory() {
428:         $this->_bShowHistory = false;
429:     }
430: 
431:     /**
432:      * Enables the delete function in the history view
433:      */
434:     public function enableHistoryDelete() {
435:         $this->_bDeleteHistoryItems = true;
436:     }
437: 
438:     /**
439:      * Disables the delete function in the history view
440:      */
441:     public function disableHistoryDelete() {
442:         $this->_bDeleteHistoryItems = false;
443:     }
444: 
445:     /**
446:      * @see cHTML::render()
447:      * @return string
448:      *         Generated markup
449:      */
450:     public function render() {
451:         global $sess;
452: 
453:         $itemtype = $this->_sItemType;
454:         $itemid = $this->_sItemID;
455: 
456:         $url = $sess->url("main.php?area=note&frame=1&itemtype=$itemtype&itemid=$itemid");
457:         $this->setEvent('click', "javascript:window.open('$url', 'todo', 'resizable=yes,scrollbars=yes,height=360,width=550');");
458: 
459:         return parent::render();
460:     }
461: }
462: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0