Documentation TYPO3 par Ameos

class.tx_sysnotepad.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is 
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 * 
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license 
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 * 
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00031 class tx_sysnotepad extends mod_user_task {
00032 
00036         function overview_main()        {
00037                 $icon = '<img src="'.$this->backPath.t3lib_extMgm::extRelPath("sys_notepad").'ext_icon.gif" width=18 height=16 class="absmiddle">';
00038                 $noteRow = $this->getQuickNote($this->BE_USER->user["uid"]);
00039                 $noteVal = nl2br(htmlspecialchars(t3lib_div::fixed_lgd(implode(chr(10),t3lib_div::trimExplode(chr(10),$noteRow["note"],1)),50)));
00040                 return $this->mkMenuConfig($icon.$this->headLink("tx_sysnotepad",1),'','<a href="index.php?SET[function]=tx_sysnotepad"  onClick="this.blur();"><img src="'.$this->backPath.'gfx/edit2.gif" style="float: left;"></a><div><a href="index.php?SET[function]=tx_sysnotepad"  onClick="this.blur();">'.$noteVal.'</a></div>');
00041         }
00042         function main() {
00043                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00044 
00045                 return $this->renderNote();
00046         }
00047 
00048 
00049 
00050 
00051         
00052         function getQuickNote($be_user_id)      {
00053                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'cruser_id='.intval($be_user_id), '', 'crdate', '1');
00054                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00055                 return $row;
00056         }
00057 
00058 
00059 
00060         // ************************
00061         // NOTES:
00062         // ***********************
00063         function renderNote()   {
00064                 global $LANG;
00065 
00066                 $out = '';
00067 
00068                         // Saving / creating note:              
00069                 $incoming = t3lib_div::_GP("data");
00070                 if (is_array($incoming["sys_notepad"])) {
00071                         $dataArr = array();
00072                         $key = key($incoming["sys_notepad"]);
00073                         if ($key=="NEW")        {
00074                                 $dataArr["note"] = $incoming["sys_notepad"]["NEW"]["note"];
00075                                 $dataArr["cruser_id"]=$this->BE_USER->user["uid"];
00076                                 $dataArr["crdate"]=time();
00077                                 $dataArr["tstamp"]=time();
00078                                 $this->setQuickNote(0,$dataArr,$this->BE_USER->user["uid"]);
00079                         } else {
00080                                 $uid = intval($key);
00081                                 $dataArr["note"] = $incoming["sys_notepad"][$uid]["note"];
00082                                 $dataArr["tstamp"]=time();
00083                                 $this->setQuickNote($uid,$dataArr,$this->BE_USER->user["uid"]);
00084                         }
00085                 }
00086                 
00087                         // Displaying edit form for note:
00088                 $note = $this->getQuickNote($this->BE_USER->user["uid"]);
00089                 if (!is_array($note))   {
00090                         $note["uid"]="NEW";
00091                 }
00092 
00093                 $out.= '<textarea rows=30'.$this->pObj->doc->formWidthText().' name="data[sys_notepad]['.$note["uid"].'][note]">'.t3lib_div::formatForTextarea($note["note"]).'</textarea>';
00094                 $out.= '<BR><input type="submit" value="'.$LANG->getLL("lUpdate").'">';
00095 
00096                         // Help text:
00097                 if ($this->BE_USER->uc["helpText"])     {
00098                         $out.= '<BR><BR>'.$this->helpBubble().$LANG->getLL("note_helpText");
00099                 }
00100 
00101                 return $this->pObj->doc->section("",$out,0,1);
00102         }
00103         function setQuickNote($uid,$inRow,$be_user_id)  {
00104                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'uid='.intval($uid));
00105                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00106                 if (is_array($row))     {       // update...
00107                         if ($be_user_id==$row["cruser_id"])     {
00108                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery("sys_notepad", "uid=".intval($uid), $inRow);
00109                         }
00110                 } else {
00111                         $GLOBALS['TYPO3_DB']->exec_INSERTquery("sys_notepad", $inRow);
00112                 }
00113         }
00114 }
00115 
00116 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]) {
00117         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]);
00118 }
00119 
00120 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6