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

classes/class.ilTabsGUI.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 
00032 class ilTabsGUI
00033 {
00034         var $target_script;
00035         var $obj_type;
00036         var $tpl;
00037         var $lng;
00038         var $tabs;
00039         var $objDefinition;
00040         var $target = array();
00041         var $sub_target = array();
00042 
00047         function ilTabsGUI()
00048         {
00049                 global $tpl, $objDefinition, $lng;
00050 
00051                 $this->tpl =& $tpl;
00052                 $this->lng =& $lng;
00053                 $this->objDefinition =& $objDefinition;
00054                 $this->manual_activation = false;
00055                 $this->subtab_manual_activation = false;
00056                 $this->temp_var = "TABS";
00057                 $this->sub_tabs = false;
00058                 $this->back_title = "";
00059                 $this->back_target = "";
00060                 $this->back_2_target = "";
00061                 $this->back_2_title = "";
00062         }
00063         
00067         function setBackTarget($a_title, $a_target, $a_frame = "")
00068         {
00069                 $this->back_title = $a_title;
00070                 $this->back_target = $a_target;
00071                 $this->back_frame = $a_frame;
00072         }
00073 
00077         function setBack2Target($a_title, $a_target, $a_frame = "")
00078         {
00079                 $this->back_2_title = $a_title;
00080                 $this->back_2_target = $a_target;
00081                 $this->back_2_frame = $a_frame;
00082         }
00083         
00084         function getTargetsByObjectType(&$a_gui_obj, $a_type)
00085         {
00086                 global $ilCtrl;
00087 
00088                 $d = $this->objDefinition->getProperties($a_type);
00089 
00090                 foreach ($d as $key => $row)
00091                 {
00092                         $this->addTarget($row["lng"],
00093                                 $ilCtrl->getLinkTarget($a_gui_obj, $row["name"]),
00094                                 $row["name"], get_class($a_gui_obj));
00095                 }
00096         }
00097 
00111         function addTarget($a_text, $a_link, $a_cmd = "", $a_cmdClass = "", $a_frame = "", $a_activate = false,
00112                 $a_dir_text = false)
00113         {
00114                 
00115                 if(!$a_cmdClass)
00116                 {
00117                         $a_cmdClass = array();
00118                 }
00119                 $a_cmdClass = !is_array($a_cmdClass) ? array(strtolower($a_cmdClass)) : $a_cmdClass;
00120                 #$a_cmdClass = strtolower($a_cmdClass);
00121 
00122                 if ($a_activate)
00123                 {
00124                         $this->manual_activation = true;
00125                 }
00126                 $this->target[] = array("text" => $a_text, "link" => $a_link,
00127                         "cmd" => $a_cmd, "cmdClass" => $a_cmdClass, "frame" => $a_frame,
00128                         "activate" => $a_activate, "dir_text" => $a_dir_text);
00129         }
00130         
00134         function clearTargets()
00135         {
00136                 $this->target = array();
00137                 $this->back_title = "";
00138                 $this->back_target = "";
00139                 $this->back_2_target = "";
00140                 $this->back_2_title = "";
00141         }
00142 
00157         function addSubTabTarget($a_text, $a_link, $a_cmd = "", $a_cmdClass = "", $a_frame = "", $a_activate = false,
00158                 $a_dir_text = false)
00159         {
00160                 
00161                 if(!$a_cmdClass)
00162                 {
00163                         $a_cmdClass = array();
00164                 }
00165                 $a_cmdClass = !is_array($a_cmdClass) ? array(strtolower($a_cmdClass)) : $a_cmdClass;
00166                 #$a_cmdClass = strtolower($a_cmdClass);
00167 
00168                 if ($a_activate)
00169                 {
00170                         $this->subtab_manual_activation = true;
00171                 }
00172                 $this->sub_target[] = array("text" => $a_text, "link" => $a_link,
00173                         "cmd" => $a_cmd, "cmdClass" => $a_cmdClass, "frame" => $a_frame,
00174                         "activate" => $a_activate, "dir_text" => $a_dir_text);
00175         }
00176 
00184         function setTabActive($a_text)
00185         {
00186                 for($i = 0; $i < count($this->target);$i++)
00187                 {
00188                         $this->target[$i]['activate'] = $this->target[$i]['text'] == $a_text;
00189                 }
00190                 if ($a_text != "")
00191                 {
00192                         $this->manual_activation = true;
00193                 }
00194                 else
00195                 {
00196                         $this->manual_activation = false;
00197                 }
00198                 return true;
00199         }
00200 
00208         function setSubTabActive($a_text)
00209         {
00210                 for($i = 0; $i < count($this->sub_target);$i++)
00211                 {
00212                         $this->sub_target[$i]['activate'] = $this->sub_target[$i]['text'] == $a_text;
00213                 }
00214                 $this->subtab_manual_activation = true;
00215                 return true;
00216         }
00217 
00223         function clearSubTabs()
00224         {
00225                 $this->sub_target = array();
00226                 return true;
00227         }
00228 
00232         function getHTML()
00233         {
00234                 return $this->__getHTML(false,$this->manual_activation);
00235         }
00236         
00240         function getSubTabHTML()
00241         {
00242                 return $this->__getHTML(true,$this->subtab_manual_activation);
00243         }
00244 
00245 
00246 
00253         function __getHTML($a_get_sub_tabs,$a_manual)
00254         {
00255                 global $ilCtrl, $lng;
00256 
00257                 $cmd = $ilCtrl->getCmd();
00258                 $cmdClass = $ilCtrl->getCmdClass();
00259 
00260                 if ($a_get_sub_tabs)
00261                 {
00262                         $tpl = new ilTemplate("tpl.sub_tabs.html", true, true);
00263                         $pre = "sub";
00264                         $pre2 = "SUB_";
00265                 }
00266                 else
00267                 {
00268                         $tpl = new ilTemplate("tpl.tabs.html", true, true);
00269                         $pre = $pre2 = "";
00270                         
00271                         // back 2 tab
00272                         if ($this->back_2_title != "")
00273                         {
00274                                 $tpl->setCurrentBlock("back_2_tab");
00275                                 $tpl->setVariable("BACK_2_TAB_LINK", $this->back_2_target);
00276                                 $tpl->setVariable("BACK_2_TAB_TEXT", $this->back_2_title);
00277                                 $tpl->setVariable("BACK_2_TAB_TARGET", $this->back_2_frame);
00278                                 $tpl->parseCurrentBlock();
00279                         }
00280                         
00281                         // back tab
00282                         if ($this->back_title != "")
00283                         {
00284                                 $tpl->setCurrentBlock("back_tab");
00285                                 $tpl->setVariable("BACK_TAB_LINK", $this->back_target);
00286                                 $tpl->setVariable("BACK_TAB_TEXT", $this->back_title);
00287                                 $tpl->setVariable("BACK_TAB_TARGET", $this->back_frame);
00288                                 $tpl->parseCurrentBlock();
00289                         }
00290                 }
00291                 
00292                 $targets = $a_get_sub_tabs ? $this->sub_target : $this->target;
00293                 // do not display one tab only
00294                 if ((count($targets) > 1) || $this->back_title != "")
00295                 {
00296                         foreach ($targets as $target)
00297                         {
00298                                 $i++;
00299                                 
00300                                 if (!is_array($target["cmd"]))
00301                                 {
00302                                         $target["cmd"] = array($target["cmd"]);
00303                                 }
00304 //echo "<br>-$a_manual-$cmd-".$target["cmd"]."-";
00305                                 if (!$a_manual &&
00306                                         (in_array($cmd, $target["cmd"]) || ($target["cmd"][0] == "" && count($target["cmd"]) == 1)) &&
00307                                         (in_array($cmdClass,$target["cmdClass"]) || !$target["cmdClass"]))
00308                                 {
00309                                         $tabtype = $pre."tabactive";
00310                                 }
00311                                 else
00312                                 {
00313                                         $tabtype = $pre."tabinactive";
00314                                 }
00315                                 
00316                                 if ($a_manual && $target["activate"])
00317                                 {
00318                                         $tabtype = $pre."tabactive";
00319                                 }
00320         
00321                                 $tpl->setCurrentBlock($pre."tab");
00322                                 $tpl->setVariable($pre2."TAB_TYPE", $tabtype);
00323                                 $tpl->setVariable($pre2."TAB_LINK", $target["link"]);
00324                                 if ($target["dir_text"])
00325                                 {
00326                                         $tpl->setVariable($pre2."TAB_TEXT", $target["text"]);
00327                                 }
00328                                 else
00329                                 {
00330                                         $tpl->setVariable($pre2."TAB_TEXT", $lng->txt($target["text"]));
00331                                 }
00332                                 $tpl->setVariable($pre2."TAB_TARGET", $target["frame"]);
00333                                 $tpl->parseCurrentBlock();
00334                         }
00335                         return $tpl->get();
00336                 }
00337                 else
00338                 {
00339                         return "";
00340                 }
00341         }
00342 }
00343 ?>

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