• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Notes/classes/class.ilPDNotesBlockGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once("Services/Block/classes/class.ilBlockGUI.php");
00025 
00034 class ilPDNotesBlockGUI extends ilBlockGUI
00035 {
00036         static $block_type = "pdnotes";
00037         
00041         function ilPDNotesBlockGUI()
00042         {
00043                 global $ilCtrl, $lng, $ilUser;
00044                 
00045                 parent::ilBlockGUI();
00046                 
00047                 $this->setLimit(5);
00048                 $this->setImage(ilUtil::getImagePath("icon_note_s.gif"));
00049                 $this->setTitle($lng->txt("notes"));
00050                 $this->setAvailableDetailLevels(3);
00051         }
00052         
00058         static function getBlockType()
00059         {
00060                 return self::$block_type;
00061         }
00062         
00068         static function isRepositoryObject()
00069         {
00070                 return false;
00071         }
00072 
00076         static function getScreenMode()
00077         {
00078                 switch($_GET["cmd"])
00079                 {
00080                         case "showNote":
00081                                 return IL_SCREEN_CENTER;
00082                                 break;
00083                                 
00084                         default:
00085                                 return IL_SCREEN_SIDE;
00086                                 break;
00087                 }
00088         }
00089 
00093         function &executeCommand()
00094         {
00095                 global $ilCtrl;
00096 
00097                 $next_class = $ilCtrl->getNextClass();
00098                 $cmd = $ilCtrl->getCmd("getHTML");
00099 
00100                 return $this->$cmd();
00101         }
00102 
00103         function getHTML()
00104         {
00105                 if ($this->getCurrentDetailLevel() == 0)
00106                 {
00107                         return "";
00108                 }
00109                 else
00110                 {
00111                         return parent::getHTML();
00112                 }
00113         }
00114         
00118         function fillDataSection()
00119         {
00120                 global $ilUser;
00121                 
00122                 include_once("Services/Notes/classes/class.ilNote.php");
00123                 $this->notes = ilNote::_getLastNotesOfUser();
00124 
00125                 if ($this->getCurrentDetailLevel() > 1 && count($this->notes) > 0)
00126                 {
00127                         $this->setRowTemplate("tpl.pd_notes_overview.html", "Services/Notes");
00128                         $this->getListRowData();
00129                         //$this->setColSpan(2);
00130                         parent::fillDataSection();
00131                 }
00132                 else
00133                 {
00134                         $this->setEnableNumInfo(false);
00135                         if (count($this->notes) == 0)
00136                         {
00137                                 $this->setEnableDetailRow(false);
00138                         }
00139                         $this->setDataSection($this->getOverview());
00140                 }
00141         }
00142         
00143 
00147         function getListRowData()
00148         {
00149                 global $ilUser, $lng, $ilCtrl;
00150 
00151                 $data = array();
00152                 
00153                 foreach($this->notes as $note)
00154                 {
00155                         switch ($note->getLabel())
00156                         {
00157                                 case IL_NOTE_UNLABELED:
00158                                         $img = ilUtil::getImagePath("note_unlabeled.gif");
00159                                         $alt = $lng->txt("note");
00160                                         break;
00161                                         
00162                                 case IL_NOTE_IMPORTANT:
00163                                         $img = ilUtil::getImagePath("note_important.gif");
00164                                         $alt = $lng->txt("note").", ".$lng->txt("important");
00165                                         break;
00166                                         
00167                                 case IL_NOTE_QUESTION:
00168                                         $img = ilUtil::getImagePath("note_question.gif");
00169                                         $alt = $lng->txt("note").", ".$lng->txt("question");
00170                                         break;
00171                                         
00172                                 case IL_NOTE_PRO:
00173                                         $img = ilUtil::getImagePath("note_pro.gif");
00174                                         $alt = $lng->txt("note").", ".$lng->txt("pro");
00175                                         break;
00176                                         
00177                                 case IL_NOTE_CONTRA:
00178                                         $img = ilUtil::getImagePath("note_contra.gif");
00179                                         $alt = $lng->txt("note").", ".$lng->txt("contra");
00180                                         break;
00181                         }
00182 
00183                         // details
00184                         $target = $note->getObject();
00185 
00186                         $data[] = array(
00187                                 "subject" => $note->getSubject(),
00188                                 "img" => $img,
00189                                 "alt" => $alt,
00190                                 "text" => ilUtil::shortenText($note->getText(), 150, true, true),
00191                                 "date" => substr($note->getCreationDate(),0,10),
00192                                 "id" => $note->getId(),
00193                                 "obj_type" => $target["obj_type"],
00194                                 "obj_id" => $target["obj_id"],
00195                                 "rep_obj_id" => $target["rep_obj_id"]);
00196                 }
00197                 
00198                 $this->setData($data);
00199         }
00200         
00204         function fillRow($a_set)
00205         {
00206                 global $ilUser, $ilCtrl, $lng;
00207                 
00208                 include_once("Services/Notes/classes/class.ilNoteGUI.php");
00209                 if (!is_object($this->note_gui))
00210                 {
00211                         $this->note_gui = new ilNoteGUI(0,0,"");
00212                         $this->note_gui->enableTargets();
00213                 }
00214 
00215                 //if ($this->getCurrentDetailLevel() > 2)
00216                 //{
00217                 //      $this->tpl->setVariable("VAL_SUBJECT", "<b>".$a_set["subject"]."</b>");
00218                 //}
00219                 //else
00220                 //{
00221                         $this->tpl->setVariable("VAL_SUBJECT", $a_set["subject"]);
00222                 //}
00223                 
00224                 // link subject to show note function
00225                 $ilCtrl->setParameter($this, "rel_obj", $a_set["rep_obj_id"]);
00226                 $ilCtrl->setParameter($this, "note_id", $a_set["id"]);
00227                 $ilCtrl->setParameter($this, "note_type", IL_NOTE_PRIVATE);
00228                 $this->tpl->setVariable("HREF_SHOW_NOTE",
00229                         $ilCtrl->getLinkTarget($this, "showNote"));
00230                 $this->tpl->setVariable("IMG_NOTE", $a_set["img"]);
00231                 $this->tpl->setVariable("ALT_NOTE", $a_set["alt"]);
00232                 $ilCtrl->clearParameters($this);
00233                 
00234                 // details
00235                 if ($this->getCurrentDetailLevel() > 2)
00236                 {
00237                         $this->tpl->setCurrentBlock("details");
00238                         $this->tpl->setVariable("NOTE_TEXT", $a_set["text"]);
00239                         $this->tpl->setVariable("VAL_DATE", $a_set["date"]);
00240                         $this->tpl->parseCurrentBlock();
00241                                 
00242                         // target objects
00243                         $this->note_gui->showTargets($this->tpl, $a_set["rep_obj_id"], $a_set["id"],
00244                                 $a_set["obj_type"], $a_set["obj_id"]);
00245 
00246                         // edit button
00247                         $this->tpl->setCurrentBlock("edit_note");
00248                         $this->tpl->setVariable("TXT_EDIT_NOTE", $lng->txt("edit"));
00249                         $ilCtrl->setParameterByClass("ilnotegui", "rel_obj", $a_set["rep_obj_id"]);
00250                         $ilCtrl->setParameterByClass("ilnotegui", "note_id", $a_set["id"]);
00251                         $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE);
00252                         $this->tpl->setVariable("LINK_EDIT_NOTE",
00253                                 $ilCtrl->getLinkTargetByClass(array("ilpersonaldesktopgui", "ilpdnotesgui", "ilnotegui"), "editNoteForm")
00254                                 ."#note_edit");
00255                         $this->tpl->parseCurrentBlock();
00256                 }
00257                 $ilCtrl->clearParametersByClass("ilnotegui");
00258         }
00259 
00263         function getOverview()
00264         {
00265                 global $ilUser, $lng, $ilCtrl;
00266                                 
00267                 return '<div class="small">'.((int) count($this->notes))." ".$lng->txt("notes")."</div>";
00268         }
00269 
00273         function showNote()
00274         {
00275                 global $lng, $ilCtrl;
00276                 
00277                 include_once("./Services/Notes/classes/class.ilNoteGUI.php");
00278                 $note_gui = new ilNoteGUI();
00279                 $note_gui->enableTargets();
00280                 include_once("./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php");
00281                 $content_block = new ilPDContentBlockGUI();
00282                 $content_block->setContent($note_gui->getPDNoteHTML($_GET["note_id"]));
00283                 $content_block->setTitle($lng->txt("note"));
00284                 $content_block->setColSpan(2);
00285                 $content_block->setImage(ilUtil::getImagePath("icon_note.gif"));
00286                 $content_block->addHeaderCommand($ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "show"),
00287                         $lng->txt("selected_items_back"));
00288                 
00289                 return $content_block->getHTML();
00290         }
00291 
00292 }
00293 
00294 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1