Documentation TYPO3 par Ameos

class.tx_sysnotepad.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@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(&$pObj)  {
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_cs(implode(chr(10),t3lib_div::trimExplode(chr(10),$noteRow["note"],1)),50)));
00040                 $content.=$pObj->doc->section(
00041                         $icon."&nbsp;".$this->headLink("tx_sysnotepad",0),
00042                         '<a href="index.php?SET[function]=tx_sysnotepad" target="list_frame" onClick="this.blur();"><img src="'.$this->backPath.'gfx/edit2.gif" width="11" height="12" hspace=2 border="0" align=top>'.$noteVal.'</a>',1,1,0,1);
00043                 return $content;
00044         }
00045         function main() {
00046                 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00047 
00048                 return $this->renderNote();
00049         }
00050 
00051 
00052 
00053 
00054 
00055         function getQuickNote($be_user_id)      {
00056                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'cruser_id='.intval($be_user_id), '', 'crdate', '1');
00057                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00058                 return $row;
00059         }
00060 
00061 
00062 
00063         // ************************
00064         // NOTES:
00065         // ***********************
00066         function renderNote()   {
00067                 global $LANG;
00068 
00069                 $out = '';
00070 
00071                         // Saving / creating note:
00072                 $incoming = t3lib_div::_GP("data");
00073                 if (is_array($incoming["sys_notepad"])) {
00074                         $dataArr = array();
00075                         $key = key($incoming["sys_notepad"]);
00076                         if ($key=="NEW")        {
00077                                 $dataArr["note"] = $incoming["sys_notepad"]["NEW"]["note"];
00078                                 $dataArr["cruser_id"]=$this->BE_USER->user["uid"];
00079                                 $dataArr["crdate"]=time();
00080                                 $dataArr["tstamp"]=time();
00081                                 $this->setQuickNote(0,$dataArr,$this->BE_USER->user["uid"]);
00082                         } else {
00083                                 $uid = intval($key);
00084                                 $dataArr["note"] = $incoming["sys_notepad"][$uid]["note"];
00085                                 $dataArr["tstamp"]=time();
00086                                 $this->setQuickNote($uid,$dataArr,$this->BE_USER->user["uid"]);
00087                         }
00088                         $out.=$this->loadLeftFrameJS();
00089                 }
00090 
00091                         // Displaying edit form for note:
00092                 $note = $this->getQuickNote($this->BE_USER->user["uid"]);
00093                 if (!is_array($note))   {
00094                         $note["uid"]="NEW";
00095                 }
00096 
00097                 $out.= '<textarea rows=30'.$this->pObj->doc->formWidthText().' name="data[sys_notepad]['.$note["uid"].'][note]">'.t3lib_div::formatForTextarea($note["note"]).'</textarea>';
00098                 $out.= '<BR><input type="submit" value="'.$LANG->getLL("lUpdate").'">';
00099 
00100                         // Help text:
00101                 if ($this->BE_USER->uc["helpText"])     {
00102                         $out.= '<BR><BR>'.$this->helpBubble().$LANG->getLL("note_helpText");
00103                 }
00104 
00105                 return $this->pObj->doc->section("",$out,0,1);
00106         }
00107         function setQuickNote($uid,$inRow,$be_user_id)  {
00108                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_notepad', 'uid='.intval($uid));
00109                 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
00110                 if (is_array($row))     {       // update...
00111                         if ($be_user_id==$row["cruser_id"])     {
00112                                 $GLOBALS['TYPO3_DB']->exec_UPDATEquery("sys_notepad", "uid=".intval($uid), $inRow);
00113                         }
00114                 } else {
00115                         $GLOBALS['TYPO3_DB']->exec_INSERTquery("sys_notepad", $inRow);
00116                 }
00117         }
00118 }
00119 
00120 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]) {
00121         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/sys_notepad/class.tx_sysnotepad.php"]);
00122 }
00123 
00124 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6