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